summaryrefslogtreecommitdiff
path: root/client/main.c
blob: c0ed27e2c37143dab45301ac07ae25537d01f388 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "raylib.h"
#include <stdio.h>
#include "net/net.h"

int main() {
  const int screenWidth = 800;
  const int screenHeight = 450;

  InitWindow(screenWidth, screenHeight, "Pants - MMO");

  SetTargetFPS(60);

  char* message = "Welcome to Pants a game by Matthew & Devyn Challman";
  int fontSize = 25;

  int messageWidth = MeasureText(message, fontSize);
  int messagePosX = (screenWidth - messageWidth) / 2;
  int messagePosY = (screenHeight - fontSize) / 2;

  int buttonW = 150;
  int buttonH = 50;
  int buttonPosX = (screenWidth - buttonW) / 2;
  int buttonPosY = (screenHeight - buttonH) / 2 + 100;

  char *connect = "Connect";
  int connectWidth = MeasureText(connect, fontSize);
  int connectPosX = (screenWidth - connectWidth) / 2;
  int connectPosY = (screenHeight - fontSize) / 2 + 100;

  while (!WindowShouldClose()) {

    bool connecting = false;
    if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) {
      struct Vector2 mousePos = GetMousePosition();

      if (mousePos.x >= buttonPosX && mousePos.x <= buttonPosX + buttonW &&
          mousePos.y >= buttonPosY && mousePos.y <= buttonPosY + buttonH) {

        connecting = true;
      }
    }

    BeginDrawing();
        ClearBackground(RAYWHITE);
        DrawText(message, messagePosX, messagePosY, fontSize, LIGHTGRAY);

	if(connecting) {
	  DrawRectangle(buttonPosX, buttonPosY, buttonW, buttonH, RED);
        } else {
          DrawRectangle(buttonPosX, buttonPosY, buttonW, buttonH, GREEN);
	}

	DrawText(connect, connectPosX, connectPosY, fontSize, BLUE);

	DrawFPS(0,0);
    EndDrawing();

    if (connecting)
      ServerConnect();
  }

  return 0;
}