forked from DKU-EmbeddedSystem-Lab/2025_DKU_OpenSourceBasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenuState.cpp
More file actions
55 lines (41 loc) · 1.38 KB
/
MainMenuState.cpp
File metadata and controls
55 lines (41 loc) · 1.38 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
#include "mainmenustate.hpp"
#include "game.hpp"
#include "config.hpp"
MainMenuState::MainMenuState(InputManager* manager)
: MenuState(manager) {}
void MainMenuState::initialize() {
title_text = new Texture();
title_text->loadFromText("PixelTetris!", Game::getInstance()->mRenderer->bigFont, config::default_text_color);
// 기존 버튼들 정리
for (auto button : mButtons) {
delete button;
}
mButtons.clear();
int buttonWidth = 200;
int buttonHeight = 50;
int centerX = (config::logical_window_width - buttonWidth) / 2;
addButton(new Button(
"PLAY",
[]() { Game::getInstance()->pushNewState<ContentSelectMenuState>(); },
centerX, 130, buttonWidth, buttonHeight
));
addButton(new Button(
"OPTIONS",
[]() { Game::getInstance()->pushNewState<MainMenuOptionsState>(); },
centerX, 190, buttonWidth, buttonHeight
));
addButton(new Button(
"EXIT",
[]() { Game::getInstance()->goBack(); },
centerX, 250, buttonWidth, buttonHeight
));
}
void MainMenuState::draw() {
Game::getInstance()->mRenderer->clearScreen();
if (title_text)
title_text->renderCentered(config::logical_window_width / 2, 50);
for (auto button : mButtons)
button->draw();
SelectionInputHandler::renderHighlight(mButtons, index);
Game::getInstance()->mRenderer->updateScreen();
}