-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmenu.cpp
More file actions
executable file
·205 lines (167 loc) · 6.24 KB
/
Copy pathmenu.cpp
File metadata and controls
executable file
·205 lines (167 loc) · 6.24 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**************
* File Name: menu.cpp
* Author: G. J. Krafsig
* Date: July 3rd, 2007
* Purpose: implementation for game menus
**************/
#include "menu.h"
/**************
* Purpose: default constructor, initialize class values
* Precondition: none
* Postcondition: none
**************/
gamemenu::gamemenu()
{
setScreen(LOADINGSCREEN); //loading the game images and data
}
/**************
* Purpose: loads the graphics for the game screens
* Precondition: width and height of the images
* Postcondition: returns true once all graphics are loaded
**************/
bool gamemenu::loadGraphics(int width, int height)
{
//loading the game graphics
loading = graphics->blitBigger(load_bitmap(LOADINGIMAGE, NULL), width/6, height/6, width, height);
//starting a new game screen
newload = graphics->blitBigger(load_bitmap(NEWGAMEIMAGE, NULL), width/6, height/6, width, height);
//selecting the game mode
gameplay = graphics->blitBigger(load_bitmap(GAMEMODEIMAGE, NULL), width/6, height/6, width, height);
//pause = graphics->blitBigger(load_bitmap(PAUSEIMAGE, NULL), width/6, height/6, width, height);
//store = graphics->blitBigger(load_bitmap(STOREIMAGE, NULL), width/6, height/6, width, height);
loadgame = graphics->blitBigger(load_bitmap(LOADGAMEIMAGE, NULL), width/6, height/6, width, height);
savegame = graphics->blitBigger(load_bitmap(SAVEGAMEIMAGE, NULL), width/6, height/6, width, height);
build = load_bitmap(BUILDLOGINIMAGE, NULL);
//the selector image
select = load_bitmap(SELECTORIMAGE, NULL);
//setup the selector
selector.x = (width/3) + 50; //selector x position
selector.y = (width/3) + 37; //selector y position
selector.w = select->w; //selector width
selector.h = select->h; //selector height
return true;
}
/**************
* Purpose: returns the current game screen
* Precondition: none
* Postcondition: current screen returned
**************/
int gamemenu::currentScreen()
{
return screen;
}
/**************
* Purpose: returns the current game screen
* Precondition: none
* Postcondition: current screen returned
**************/
bool gamemenu::setScreen(int num)
{
screen = num;
shown = false;
selector.show = false;
selector.display = true;
//don't show the selector for loading screen
if (num == 1)
selector.display = false;
}
/**************
* Purpose: change the x position of the selector
* Precondition: amount to move selector
* Postcondition: selector positions changed, selector shown value updated
**************/
void gamemenu::setSelectorY(int amount)
{
selector.y += amount;
selector.show = false;
}
/**************
* Purpose: change the y position of the selector
* Precondition: amount to move selector
* Postcondition: selector positions changed, selector shown value updated
**************/
void gamemenu::setSelectorX(int amount)
{
selector.x += amount;
selector.show = false;
}
/**************
* Purpose: returns the game selector image
* Precondition: selector image is open
* Postcondition: selector image returned
**************/
BITMAP *gamemenu::getSelector()
{
return select;
}
/**************
* Purpose: returns a specific bitmap screen when requested, otherwise
* it returns the current game screen
* Precondition: number of the screen to return
* Postcondition: requested bitmap is returned or current screen bitmap is
* returned if no specific bitmap was requested
**************/
BITMAP *gamemenu::getScreen(int num)
{
if (num) //requesting a specific one
switch (num)
{
case LOADINGSCREEN: return loading; //loading data and images
break;
case NEWGAMESCREEN: return newload; //loading a new game
break;
case GAMEMODESCREEN: return gameplay; //selecting the gameplay mode
break;
case PAUSESCREEN: return pause; //showing the pause screen
break;
case STORESCREEN: return store; //showing the store screen
break;
case LOADGAMESCREEN: return loadgame; //loading a previous game screen
break;
case SAVEGAMESCREEN: return savegame; //saving a game screen
break;
case BUILDLOGINSCREEN: return build; //build login screen
break;
default: return NULL;
break;
}
else //return the screen currently being used
switch (screen)
{
case LOADINGSCREEN: return loading; //loading data and images
break;
case NEWGAMESCREEN: return newload; //loading a new game
break;
case GAMEMODESCREEN: return gameplay; //selecting the gameplay mode
break;
case PAUSESCREEN: return pause; //showing the pause screen
break;
case STORESCREEN: return store; //showing the store screen
break;
case LOADGAMESCREEN: return loadgame; //loading a previous game screen
break;
case SAVEGAMESCREEN: return savegame; //saving a game screen
break;
case BUILDLOGINSCREEN: return build; //build login screen
break;
default: return NULL;
break;
}
}
/**************
* Purpose: free up the memory allocated in this object
* Precondition: images already exist
* Postcondition: memory is released
**************/
void gamemenu::destoryGraphics()
{
destroy_bitmap(loading);
destroy_bitmap(newload);
destroy_bitmap(gameplay);
//destroy_bitmap(pause);
//destroy_bitmap(store);
destroy_bitmap(loadgame);
destroy_bitmap(savegame);
destroy_bitmap(select);
destroy_bitmap(build);
}