-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenuState.cpp.save
More file actions
102 lines (85 loc) · 3.86 KB
/
MainMenuState.cpp.save
File metadata and controls
102 lines (85 loc) · 3.86 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
/**
* @file MainMenuState.cpp
* @brief Main Menu State Implementation
*/
#include "GameState.hpp"
#include "../include/GameEngine.hpp"
#include "UIComponents.hpp"
#include <memory>
namespace Queah {
void MainMenuState::enter() {
// Initialize menu
}
void MainMenuState::exit() {
// Cleanup
}
void MainMenuState::update(float deltaTime) {
// Menu logic
}
void MainMenuState::handleInput() {
Vector2 mousePos = GetMousePosition();
Rectangle jogarBtn = {200, 360, 300, 100};
Rectangle criadoresBtn = {250, 490, 200, 70};
Rectangle regrasBtn = {250, 580, 200, 70};
Rectangle historicoBtn = {250, 670, 200, 70};
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) {
if (CheckCollisionPointRec(mousePos, jogarBtn)) {
engine_->changeState(std::make_unique<PlayerSetupState>(engine_, 1));
} else if (CheckCollisionPointRec(mousePos, criadoresBtn)) {
engine_->changeState(std::make_unique<CreditsState>(engine_));
} else if (CheckCollisionPointRec(mousePos, regrasBtn)) {
engine_->changeState(std::make_unique<RulesState>(engine_));
} else if (CheckCollisionPointRec(mousePos, historicoBtn)) {
engine_->changeState(std::make_unique<HistoryState>(engine_));
}
}
}
void MainMenuState::render() {
// Title
const char* title = "Queah";
int titleWidth = MeasureText(title, 60);
DrawText(title, (720 - titleWidth) / 2, 100, 60, BLACK);
// Subtitle
const char* subtitle = "Refactored Edition";
int subtitleWidth = MeasureText(subtitle, 20);
DrawText(subtitle, (720 - subtitleWidth) / 2, 180, 20, DARKGRAY);
// Buttons
Vector2 mousePos = GetMousePosition();
Rectangle jogarBtn = {200, 360, 300, 100};
Rectangle criadoresBtn = {250, 490, 200, 70};
Rectangle regrasBtn = {250, 580, 200, 70};
Rectangle historicoBtn = {250, 670, 200, 70};
// Draw Jogar button
Color jogarColor = CheckCollisionPointRec(mousePos, jogarBtn) ? DARKGRAY : LIGHTGRAY;
DrawRectangleRec(jogarBtn, jogarColor);
DrawRectangleLinesEx(jogarBtn, 3, BLACK);
const char* jogarText = "JOGAR";
int jogarWidth = MeasureText(jogarText, 40);
DrawText(jogarText, jogarBtn.x + (jogarBtn.width - jogarWidth) / 2,
jogarBtn.y + 30, 40, CheckCollisionPointRec(mousePos, jogarBtn) ? WHITE : BLACK);
// Draw Criadores button
Color criadoresColor = CheckCollisionPointRec(mousePos, criadoresBtn) ? DARKGRAY : LIGHTGRAY;
DrawRectangleRec(criadoresBtn, criadoresColor);
DrawRectangleLinesEx(criadoresBtn, 2, BLACK);
const char* criadoresText = "Criadores";
int criadoresWidth = MeasureText(criadoresText, 20);
DrawText(criadoresText, criadoresBtn.x + (criadoresBtn.width - criadoresWidth) / 2,
criadoresBtn.y + 25, 20, CheckCollisionPointRec(mousePos, criadoresBtn) ? WHITE : BLACK);
// Draw Regras button
Color regrasColor = CheckCollisionPointRec(mousePos, regrasBtn) ? DARKGRAY : LIGHTGRAY;
DrawRectangleRec(regrasBtn, regrasColor);
DrawRectangleLinesEx(regrasBtn, 2, BLACK);
const char* regrasText = "Regras";
int regrasWidth = MeasureText(regrasText, 20);
DrawText(regrasText, regrasBtn.x + (regrasBtn.width - regrasWidth) / 2,
regrasBtn.y + 25, 20, CheckCollisionPointRec(mousePos, regrasBtn) ? WHITE : BLACK);
// Draw Historico button
Color historicoColor = CheckCollisionPointRec(mousePos, historicoBtn) ? DARKGRAY : LIGHTGRAY;
DrawRectangleRec(historicoBtn, historicoColor);
DrawRectangleLinesEx(historicoBtn, 2, BLACK);
const char* historicoText = "Histórico";
int historicoWidth = MeasureText(historicoText, 20);
DrawText(historicoText, historicoBtn.x + (historicoBtn.width - historicoWidth) / 2,
historicoBtn.y + 25, 20, CheckCollisionPointRec(mousePos, historicoBtn) ? WHITE : BLACK);
}
} // namespace Queah