-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainMenuState.cpp
97 lines (79 loc) · 2.08 KB
/
MainMenuState.cpp
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
#include "EndState.h"
#include "LevelSelectState.h"
#include "StartGameState.h"
MainMenuState::MainMenuState() : m_selectionBox(80, 90)
{
mixer_ch_stop(AUDIO_CHANNEL_MUSIC);
mixer_ch_stop(AUDIO_CHANNEL_SFX);
camera.resetCamera();
camera.Transform();
glClearColor(0, 0, 0, 1);
textureMan::clearTextures();
modelMan::clearModels();
textureMan::loadTexture("rom:/skybox.sprite");
modelMan::loadModel("rom:/skybox.model64");
utils::loadControlTextures();
skybox.setModel("skybox");
skybox.setTexture("skybox");
skybox.setScale({100.0f, 100.0f, 100.0f});
m_selectionBox.addOption("Start Game");
m_selectionBox.addOption("Controls");
m_selectionBox.addOption("Level Select");
if(global::saveFile.completed)
{
m_selectionBox.addOption("High Scores");
}
}
void MainMenuState::execute()
{
if (audio_can_write())
{
short *buf = audio_write_begin();
mixer_poll(buf, audio_get_buffer_length());
audio_write_end();
}
controller_scan();
if(viewingControls)
{
struct controller_data down = get_keys_down();
if(down.c[0].B)
{
viewingControls = false;
}
return;
}
switch(m_selectionBox.execute(m_cursorMove))
{
case START_GAME:
nextState = new StartGameState();
break;
case LEVEL_SELECT:
nextState = new LevelSelectState();
break;
case INSTRUCTIONS:
viewingControls = true;
break;
case HIGH_SCORES:
nextState = new EndState();
break;
}
}
void MainMenuState::renderGl()
{
skybox.draw();
}
void MainMenuState::renderRdpq()
{
if(viewingControls)
{
utils::drawControls();
return;
}
rdpq_font_begin(RGBA32(0xff, 0xff, 0xff, 0xFF));
rdpq_font_scale(1.0f, 1.0f);
rdpq_font_position(60.0f, 45.0f);
rdpq_font_print(global::font, "Sand Castle");
rdpq_font_position(90.0f, 70.0f);
rdpq_font_print(global::font, "Clamour!");
m_selectionBox.draw();
}