-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.h
More file actions
218 lines (179 loc) · 6.28 KB
/
Copy pathoptions.h
File metadata and controls
218 lines (179 loc) · 6.28 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
206
207
208
209
210
211
212
213
214
215
216
217
218
#ifndef OPTIONS_H_INCLUDED
#define OPTIONS_H_INCLUDED
#include "variables.h"
#include "dropbox.h"
#include "button.h"
std::vector<const wchar_t*> difficulties;
text player_names_wchr = L"Player names:";
void db1()
{
if (!widgets_updated) dropBox(4, 30, 13, names, player1);
}
void db2()
{
if (!widgets_updated) dropBox(4, 46, 13, names, player2);
}
text box_wchr = {9484, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9488,
9474, L' ', L' ', L' ', L' ', L' ', L' ', L' ', L' ', L' ', L' ', 9660, 9474,
9492, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9496, 0};
text score_reset_text = {9484, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9488,
9474, L'R', L'e', L's', L'e', L't', L' ', L's', L'c', L'o', L'r', L'e', 9474,
9492, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9496, 0};
text change_turn_text = {9484, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9488,
9474, L'C', L'h', L'a', L'n', L'g', L'e', L' ', L'd', L'e', L'f', L'a', L'u', L'l', L't', 9474,
9492, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9496, 0};
text acc_check_box_text = {L' ', L'_', L' ',
9474, L' ', 9474,
L' ', 175, L' ', 0};
void drawBox(int ipos, int jpos, int isize, int jsize)
{
wchar_t ch = WHITE_SPACE;
for(int i = ipos; i < ipos+isize-1; i++)
{
print(ch, jpos, i);
print(ch, jpos + jsize-1, i);
}
for(int j = jpos; j < jpos+jsize-1; j++)
{
print(ch, j, ipos);
print(ch, j, ipos+isize-1);
}
print(ch, jpos+jsize-1, ipos+isize-1);
}
void swapNames()
{
wchar_t *aux = new wchar_t[11];
wstrcpy(aux, player1);
wstrcpy(player1, player2);
wstrcpy(player2, aux);
delete [] aux;
int au = score1;
score1 = score2;
score2 = au;
}
/* The boxes that are used to input custom names */
Button p1_naming_box(2, 30, 3, 13, box_wchr, db1);
Button p2_naming_box(2, 46, 3, 13, box_wchr, db2);
/* The button that sets both scores to 0 */
Button reset_score(6, 51, 3, 13, score_reset_text, resetScore);
/* swaps names */
Button swap_names(3, 44, 1, 1, "", swapNames);
/* difficulty dropdown */
DropDown difficulty_drop(28, 11);
static int cell = 0;
void optionsScene()
{
cell = 0;
scene = 2;
}
void options()
{
print(player_names_wchr, 15, 3);
p1_naming_box.update();
swap_names.update();
p2_naming_box.update();
p1_naming_box.draw();
print((wchar_t)8596, 44, 3);
p2_naming_box.draw();
print(player1, 31, 3);print((wchar_t)9660, 41, 3);
print(player2, 47, 3);print((wchar_t)9660, 57, 3);
reset_score.draw();
switch (cell)
{
case 0: /* no key has been pressed yet */
{
if (keyboard.isKeyPressed(VK_LEFT) ||
keyboard.isKeyPressed(VK_UP) ||
keyboard.isKeyPressed(VK_RIGHT) ||
keyboard.isKeyPressed(VK_DOWN) ||
keyboard.isKeyPressed('A') ||
keyboard.isKeyPressed('W') ||
keyboard.isKeyPressed('S') ||
keyboard.isKeyPressed('D')
)
cell = 1;
break;
}
case 1:
{
if (keyboard.isKeyPressed(VK_RIGHT) ||
keyboard.isKeyPressed('D'))
{ cell = 2; break; }
if (keyboard.isKeyPressed(VK_LEFT) ||
keyboard.isKeyPressed('A'))
{ cell = 3; break; }
if(keyboard.isKeyPressed(VK_DOWN) ||
keyboard.isKeyPressed('S') ||
keyboard.isKeyPressed(VK_UP) ||
keyboard.isKeyPressed('W'))
{cell = 4; break;}
drawBox(2, 30, 3, 13);
if(keyboard.isKeyPressed(VK_RETURN) ||
keyboard.isKeyPressed(VK_SPACE))
db1();
break;
}
case 2:
{
drawBox(4, 44, 1, 1);
if (keyboard.isKeyPressed('A')
||keyboard.isKeyPressed(VK_LEFT))
{ cell = 1; break; }
if (keyboard.isKeyPressed('D')
||keyboard.isKeyPressed(VK_RIGHT))
{ cell = 3; break; }
if (keyboard.isKeyPressed('S') || keyboard.isKeyPressed('W')
||keyboard.isKeyPressed(VK_DOWN) || keyboard.isKeyPressed(VK_UP))
{cell = 4; break; }
if (keyboard.isKeyPressed(VK_SPACE) || keyboard.isKeyPressed(VK_RETURN))
{ swapNames(); }
break;
}
case 3:
{
drawBox(2, 46, 3, 13);
if (keyboard.isKeyPressed(VK_RIGHT) ||
keyboard.isKeyPressed('D'))
{cell = 1; break; }
if (keyboard.isKeyPressed(VK_LEFT) ||
keyboard.isKeyPressed('A'))
{cell = 2; break; }
if(keyboard.isKeyPressed(VK_DOWN) ||
keyboard.isKeyPressed('S') ||
keyboard.isKeyPressed(VK_UP) ||
keyboard.isKeyPressed('W'))
{cell = 4; break;}
if(keyboard.isKeyPressed(VK_RETURN) ||
keyboard.isKeyPressed(VK_SPACE))
db2();
break;
}
case 4:
{
drawBox(6, 51, 3, 13);
if(keyboard.isKeyPressed(VK_UP) ||
keyboard.isKeyPressed('W'))
cell = 3;
if(keyboard.isKeyPressed(VK_DOWN) ||
keyboard.isKeyPressed('S'))
cell = 1;
if(keyboard.isKeyPressed(VK_RETURN) ||
keyboard.isKeyPressed(VK_SPACE))
resetScore();
break;
}
default: break;
}//switch
int iterator;
iterator = print("Score:", 15, 7);
iterator = print(player1, iterator);
iterator = print(score1 , iterator);
iterator = print('|' , iterator);
iterator = print(score2 , iterator);
iterator = print(player2, iterator);
reset_score.update();
print("Difficulty:", 15, 11);
difficulty_drop.update();
difficulty_drop.render();
}
#endif // OPTIONS_H_INCLUDED