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
|
#include "raylib.h"
#include <stdio.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 (IsMouseButtonDown(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);
DrawRectangle(buttonPosX, buttonPosY, buttonW, buttonH, GREEN);
if(connecting)
DrawText(connect, connectPosX, connectPosY, fontSize, RED);
else
DrawText(connect, connectPosX, connectPosY, fontSize, BLUE);
DrawFPS(0,0);
EndDrawing();
}
return 0;
}
|