forked from Huy203/CrossingGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenuGame.h
121 lines (119 loc) · 2.66 KB
/
MenuGame.h
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
#pragma once
#include "ConsoleWindow.h"
#include"Sound.h"
#include <iostream>
#include <deque>
#include <string>
using namespace std;
static bool g_sound = true;
static bool g_music_button = false;
static bool g_music_menu = true;
static bool sound_temp = true;
static bool introduction_page = 0;
class MenuGame
{
BUTTON menuMode;
BUTTON hotButton;
bool running;
public:
void loadSettings(Input* input) {
render_state = getRender();
Renderer::draw_Settings(0, 0, 0, 0, sound_temp);
if (pressed(BUTTON_B)) {
is_down(BUTTON_B) = false;
menuMode = MAIN;
}
if ((pressed(BUTTON_LEFT)||pressed(BUTTON_A)) && sound_temp == true) sound_temp = false;
if ((pressed(BUTTON_RIGHT) || pressed(BUTTON_D)) && !sound_temp == true) sound_temp = true;
if (pressed(BUTTON_ENTER)) {
g_music_menu = sound_temp;
if (g_music_menu)
Sound::audioMenu();
else
Sound::audioStop();
}
}
void loadIntroduction(Input* input) {
render_state = getRender();
Renderer::draw_Introduction(0, 0, 0, 0, introduction_page);
if (pressed(BUTTON_LEFT) || pressed(BUTTON_A)) introduction_page = 0;
if (pressed(BUTTON_RIGHT) || pressed(BUTTON_D)) introduction_page = 1;
if (pressed(BUTTON_B)) {
introduction_page = 1;
is_down(BUTTON_B) = false;
menuMode = MAIN;
}
}
MenuGame() {
menuMode = MAIN;
hotButton = NEW_GAME;
Sound::audioMenu();
running = true;
}
bool isRunning() {
return running;
}
void setRunning(bool check) {
running = check;
}
BUTTON getMenuMode() {
return menuMode;
}
void setMenuMode(BUTTON newNode) {
menuMode = newNode;
running = true;
}
void loadMainMenu(Input* input) {
render_state = getRender();
if (pressed(BUTTON_S))
{
g_music_button = !g_music_button;
if (g_music_button)
{
Sound::audioButton();
}
g_music_button = !g_music_button;
hotButton = (BUTTON)(hotButton + 1);
if (hotButton > 4)hotButton = EXIT;
}
if (pressed(BUTTON_W)) {
g_music_button = !g_music_button;
if (g_music_button)
{
Sound::audioButton();
}
g_music_button = !g_music_button;
hotButton = (BUTTON)(hotButton - 1);
if (hotButton < 0)hotButton = NEW_GAME;
}
if (pressed(BUTTON_ENTER))
{
is_down(BUTTON_ENTER) = false;
menuMode = hotButton;
}
Renderer::draw_Menu(0, 0, 50, 50, hotButton);
}
void loadMenuGame(Input* input) {
Renderer::clear_screen(0x01C4FF);
render_state = getRender();
switch (menuMode) {
case MAIN:
loadMainMenu(input);
break;
case NEW_GAME:
running = false;
break;
case LOAD_GAME:
return;
case SETTINGS:
loadSettings(input);
break;
case INTRODUCTION:
loadIntroduction(input);
break;
case EXIT:
menuMode = EXIT;
break;
}
}
};