-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu2.cpp
More file actions
153 lines (120 loc) · 4.82 KB
/
Copy pathmenu2.cpp
File metadata and controls
153 lines (120 loc) · 4.82 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "raylib.h"
void DrawCenteredText(const char *text, Rectangle rect, int fontSize, Color color)
{
int textWidth = MeasureText(text, fontSize);
DrawText(
text,
rect.x + (rect.width - textWidth) / 2,
rect.y + (rect.height - fontSize) / 2,
fontSize,
color
);
}
int main()
{
const int screen_Width = 1000;
const int screen_Height = 1000;
InitWindow(screen_Width, screen_Height, "Mini Arcade Game System");
SetTargetFPS(30);
float button_width = 200;
float button_height = 100;
float startX = (screen_Width - button_width) / 2;
float total_Height = (button_height * 5) + (40 * 4);
float startY = (screen_Height - total_Height) / 2;
Rectangle snake = { startX, startY, button_width, button_height };
Rectangle ttt = { startX, startY + (button_height + 40) * 1, button_width, button_height };
Rectangle maze = { startX, startY + (button_height + 40) * 2, button_width, button_height };
Rectangle score = { startX, startY + (button_height + 40) * 3, button_width, button_height };
Rectangle exit = { startX, startY + (button_height + 40) * 4, button_width, button_height };
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground((Color){20, 20, 40, 255});
Vector2 mouse = GetMousePosition();
bool hoverplay = CheckCollisionPointRec(mouse, snake);
bool hoverttt = CheckCollisionPointRec(mouse, ttt);
bool hoverMaze = CheckCollisionPointRec(mouse, maze);
bool hoverScore = CheckCollisionPointRec(mouse, score);
bool hoverexit = CheckCollisionPointRec(mouse, exit);
DrawRectangleRec(snake, hoverplay ? DARKBLUE : (Color){0, 200, 255, 255});
DrawRectangleRec(ttt, hoverttt ? DARKBLUE : (Color){0, 200, 255, 255});
DrawRectangleRec(maze, hoverMaze ? DARKBLUE : (Color){0, 200, 255, 255});
DrawRectangleRec(score, hoverScore ? DARKGREEN : GREEN);
DrawRectangleRec(exit, hoverexit ? (Color){120, 20, 20, 255} : RED);
DrawText("GAME OPTIONS", startX - 80, startY - 125, 50, WHITE);
// Centered button text
DrawCenteredText("SNAKE", snake, 30, BLACK);
DrawCenteredText("TIC TAC TOE", ttt, 25, BLACK);
DrawCenteredText("MAZE", maze, 30, BLACK);
DrawCenteredText("SCORE", score, 30, BLACK);
DrawCenteredText("EXIT", exit, 30, BLACK);
if ((CheckCollisionPointRec(mouse, snake) &&
IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ||
IsKeyPressed(KEY_S))
{
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(BLACK);
DrawText("SNAKE GAME", 300, 450, 60, GREEN);
DrawText("Press B to go back", 350, 550, 30, WHITE);
if (IsKeyPressed(KEY_B))
break;
EndDrawing();
}
}
if ((CheckCollisionPointRec(mouse, ttt) &&
IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ||
IsKeyPressed(KEY_T))
{
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(BLACK);
DrawText("TIC TAC TOE GAME", 220, 450, 60, GREEN);
DrawText("Press B to go back", 350, 550, 30, WHITE);
if (IsKeyPressed(KEY_B))
break;
EndDrawing();
}
}
if ((CheckCollisionPointRec(mouse, maze) &&
IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ||
IsKeyPressed(KEY_M))
{
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(BLACK);
DrawText("MAZE GAME", 320, 450, 60, GREEN);
DrawText("Press B to go back", 350, 550, 30, WHITE);
if (IsKeyPressed(KEY_B))
break;
EndDrawing();
}
}
if ((CheckCollisionPointRec(mouse, score) &&
IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ||
IsKeyPressed(KEY_TAB))
{
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(BLACK);
DrawText("GAME SCORE", 300, 450, 60, GREEN);
DrawText("Press B to go back", 350, 550, 30, WHITE);
if (IsKeyPressed(KEY_B))
break;
EndDrawing();
}
}
if (CheckCollisionPointRec(mouse, exit) &&
IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
CloseWindow();
}
EndDrawing();
}
CloseWindow();
return 0;
}