-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
324 lines (297 loc) · 5.59 KB
/
main.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
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
//xboxdude41
//austinnonos
#include <lvp\string.h>
#include <lvp\vector.h>
#include <lvp\gui_top.h>
#include <lvp\random.h>
#include <lvp\vector.h>
class PanelClass
{
public:
PanelClass();
PanelClass(int mon, int x, int y);
void DisplayPanelOn();
void DisplayPanelOff();
void DelPanel();
int GetMon();
bool IsDel();
private:
bool del;
int mon, x, y;
};
PanelClass::PanelClass()
:mon(0), x(0), y(0), del(true)
{
}
PanelClass::PanelClass(int amon, int ax, int ay)
:mon(amon), x(ax), y(ay), del(false)
{
}
void PanelClass::DisplayPanelOn() //panel display function
{
SetFillColor(YELLOW);
FilledRectangle(x, y, x + 100, y + 30);
gotoxy(x + 50, y + 15);
DrawCenteredText(mon);
}
void PanelClass::DisplayPanelOff() //panel display function
{
SetFillColor(RED);
FilledRectangle(x, y, x + 100, y + 30);
gotoxy(x + 50, y + 15);
DrawCenteredText(mon);
}
void PanelClass::DelPanel()//delete panel function
{
del = true;
}
int PanelClass::GetMon()
{
return mon;
}
bool PanelClass::IsDel()
{
return del;
}
class BriefcaseClass
{
public:
BriefcaseClass();
BriefcaseClass(int num, int mon, int x, int y, String mod);
void Draw();
bool IsHit(int x, int y);
bool isopen();
void opena();
int GetMon();
private:
int num, mon, x, y;
String mod;
bool open;
};
BriefcaseClass::BriefcaseClass()
:num(0), mon(0), x(0), y(0), mod(""), open(true)
{
}
BriefcaseClass::BriefcaseClass(int anum, int amon, int ax, int ay, String amod)
:num(anum), mon(amon), x(ax), y(ay), mod(amod), open(false)
{
}
void BriefcaseClass::Draw()
{
SetThickness(10);//Handle
SetColor(BLACK);
Rectangle(x + 50, y + 10, x + 100, y -25);
SetThickness(2);//BriefCase
SetFillColor(GRAY);
FilledRectangle(x, y, x + 150, y + 100);
gotoxy(x + 80, y + 30);
DrawCenteredText(num);
gotoxy(x + 80, y + 60);
DrawCenteredText(mod);
}
bool BriefcaseClass::IsHit(int x_, int y_)
/* Returns true if and only if point (x,y) is on the button */
{
if (x_ >= x && x_ <= x + 150 && y_ >= y && y_ <= y + 100)
{
return true;
}
else
{
return false;
}
}
bool BriefcaseClass::isopen()
{
return open;
}
void BriefcaseClass::opena()
{
SetThickness(10);//Handle
SetColor(BLACK);
Rectangle(x + 50, y + 10, x + 100, y -25);
SetThickness(2);//BriefCase
SetFillColor(BLACK);
FilledRectangle(x, y, x + 150, y + 100);
gotoxy(x + 80, y + 30);
DrawCenteredText(mon);
open = true;
}
int BriefcaseClass::GetMon()
{
return mon;
}
class GameplayClass
{
public:
GameplayClass();
void displayBriefcase();
void displayPanels();
void draw(int x, int y);
private:
vector<PanelClass> panels;
vector<BriefcaseClass> cases;
};
GameplayClass::GameplayClass()
{
vector<String> model(26);
vector<int> money(26, 0);
vector<int> cmoney(26);
vector<PanelClass> p(26);
vector<BriefcaseClass> t(26);
int panx = 10, pany = 10, casex = 400, casey = 60, ran;
model[0] = "Lily Aldridge";
model[1] = "Alessandra Ambrosio";
model[2] = "Tyra Banks";
model[3] = "Gisele Bündchen";
model[4] = "Laetitia Casta";
model[5] = "Helena Christensen";
model[6] = "Selita Ebanks";
model[7] = "Lindsay Ellingson";
model[8] = "Izabel Goulart";
model[9] = "Kate Grigorieva";
model[10] = "Erin Heatherton";
model[11] = "Taylor Marie Hill";
model[12] = "Elsa Hosk";
model[13] = "Martha Hunt";
model[14] = "Chanel Iman";
model[15] = "Jac Jagaciak";
model[16] = "Miranda Kerr";
model[17] = "Karlie Kloss";
model[18] = "Heidi Klum";
model[19] = "Doutzen Kroes";
model[20] = "Adriana Lima";
model[21] = "Stella Maxwell";
model[22] = "Marisa Miller";
model[23] = "Karen Mulder";
model[24] = "Chandra North";
model[25] = "Stephanie Seymour";
money[0] = 0;
money[1] = 1;
money[2] = 5;
money[3] = 10;
money[4] = 25;
money[5] = 50;
money[6] = 75;
money[7] = 100;
money[8] = 200;
money[9] = 300;
money[10] = 400;
money[11] = 500;
money[12] = 750;
money[13] = 1000;
money[14] = 5000;
money[15] = 10000;
money[16] = 25000;
money[17] = 50000;
money[18] = 75000;
money[19] = 100000;
money[20] = 200000;
money[21] = 300000;
money[22] = 400000;
money[23] = 500000;
money[24] = 750000;
money[25] = 1000000;
for (int i = 0; i < p.length() - 1; i++)
{
p[i] = PanelClass(money[i], panx, pany);
pany += 35;
}
panels = p;
for (i = 0; i < 26; i++)
{
do
{
ran = random(26);
if (money[ran] != -1)
{
cmoney[i] = money[ran];
money[ran] = -1;
}
}
while(cmoney[i] == 0);
}
for (i = 0; i < t.length() - 1; i++)
{
t[i] = BriefcaseClass(i + 1, cmoney[i], casex, casey, model[i]);
casex += 200;
if (casex > 1250)
{
casex = 400;
casey += 130;
}
}
cases = t;
}
void GameplayClass::displayBriefcase()
{
for(int i = 0; i < cases.length() - 1; i++)
{
if(!cases[i].isopen())
{
cases[i].Draw();
}
}
}
void GameplayClass::displayPanels()
{
for (int i = 0; i < panels.length() - 1; i++)
{
if (!panels[i].IsDel())
{
panels[i].DisplayPanelOn();
}
else
{
panels[i].DisplayPanelOff();
}
}
}
void GameplayClass::draw(int x, int y)
{
displayBriefcase();
displayPanels();
for (int i = 0; i < cases.length() - 1; i++)
{
if(cases[i].IsHit(x, y))
{
cases[i].opena();
for (int j = 0; j < panels.length() - 1; j++)
{
if (cases[i].GetMon() == panels[j].GetMon())
{
panels[j].DelPanel();
}
}
}
}
}
class GuiClass
{
public:
GuiClass();
void GuiMouseClick(int x, int y);
void GuiPaint();
String Title();
private:
GameplayClass game;
int x, y;
};
GuiClass::GuiClass()
:game()
{
}
String GuiClass::Title()
{
return "Deal or No Deal";
}
void GuiClass::GuiMouseClick(int x_, int y_)
{
x = x_;
y = y_;
}
void GuiClass::GuiPaint()
{
game.draw(x, y);
}
#include <lvp\gui_bot.h>