forked from DKU-EmbeddedSystem-Lab/2025_DKU_OpenSourceBasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModeSelectState.cpp
More file actions
74 lines (59 loc) · 2.02 KB
/
ModeSelectState.cpp
File metadata and controls
74 lines (59 loc) · 2.02 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
#include "modeselectstate.hpp"
#include "game.hpp"
#include "config.hpp"
#include <iostream>
#include "content1menustate.hpp"
#include "content2menustate.hpp"
#include "content3menustate.hpp"
ModeSelectState::ModeSelectState(InputManager* manager)
: MenuState(manager), descriptionTexture(nullptr) {}
void ModeSelectState::initialize() {
index = 0;
title_text = new Texture();
title_text->loadFromText("TETRIS", Game::getInstance()->mRenderer->bigFont, config::default_text_color);
descriptionTexture = new Texture();
descriptionTexture->loadFromText("Select Mode", Game::getInstance()->mRenderer->mediumFont, config::default_text_color);
int centerX = (config::logical_window_width - 200) / 2;
addButton(new Button(
"Single Mode",
[]() {
std::cout << "Single Mode Started!" << std::endl;
Game::getInstance()->pushNewState<GameState>();
},
centerX, 150, 200, 40
));
addButton(new Button(
"Multi Mode",
[]() {
std::cout << "Multi Mode Started!" << std::endl;
Game::getInstance()->pushNewState<MultiState>();
},
centerX, 200, 200, 40
));
addButton(new Button(
"Challenge Mode",
[]() {
std::cout << "Challenge Mode Started!" << std::endl;
Game::getInstance()->pushNewState<ChallengeMenuState>();
},
centerX, 250, 200, 40
));
addButton(new Button(
"Back",
[]() {
Game::getInstance()->popState();
},
centerX, 300, 200, 40
));
}
void ModeSelectState::draw() {
Game::getInstance()->mRenderer->clearScreen();
if (title_text)
title_text->renderCentered(config::logical_window_width / 2, 50);
if (descriptionTexture)
descriptionTexture->renderCentered(config::logical_window_width / 2, 90);
for (auto button : mButtons)
button->draw();
SelectionInputHandler::renderHighlight(mButtons, index);
Game::getInstance()->mRenderer->updateScreen();
}