-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeal or no meal.cpp
380 lines (348 loc) · 6.75 KB
/
deal or no meal.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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
#include<lvp\gui_top.h>
#include<lvp\string.h>
#include<lvp\vector.h>
#include<lvp\matrix.h>
#include<lvp\random.h>
#include<time.h>
#include<sstream>
#include<string>
void wait(double sec)
{
double wt = clock() + (sec * 1000);
while (clock() < wt)
{
}
}
String stringify(int num)
{
std::stringstream comp; //creates a new string stream
std::string temp; //creates a cstring to s
String rv = "";
comp << num;
temp = comp.str();
for (int i = 0; i < temp.size(); i++)
{
rv += temp[i];
}
return rv;
}
String formatcash(int mon)
{
String rmon = stringify(mon);
String rv = "";
for (int i = rmon.length() - 1; i >= 0; i--)
{
rv += rmon[i];
}
return rv;
}
class Suitcase
{
private:
int boxnum, monval, xt, yt;
String model;
bool open;
public:
Suitcase();
Suitcase(int box, int monval, int xpos, int ypos, String model);
bool isHit(int x, int y);
void paint();
void openbox();
int boxacc();
bool opacc();
};
Suitcase::Suitcase()
:boxnum(0), monval(0), xt(0), yt(0), model(""), open(false)
{
}
Suitcase::Suitcase(int boxnum_, int monval_, int xt_, int yt_, String model_)
:boxnum(boxnum_), monval(monval_), xt(xt_), yt(yt_), model(model_), open(false)
{
}
bool Suitcase::isHit(int x, int y)
{
if (x >= xt && x <= xt + 150 && y >= yt && y <= yt + 100)
{
return true;
}
if (x >= xt + 50 && y >= yt - 30 && x <= xt + 60 && y <= yt)
{
return true;
}
if (x >= xt + 50 && y >= yt - 30 && x <= xt + 100 && y <= yt - 20)
{
return true;
}
if (x <= xt + 100 && y >= yt - 30 && x >= xt + 90 && y <= yt)
{
return true;
}
return false;
}
void Suitcase::paint()
{
SetFillColor(RGB(96, 96, 96));
FilledRectangle(xt, yt, xt + 150, yt + 100); //body
SetFillColor(RGB(102, 51, 0));
FilledRectangle(xt + 50, yt - 30, xt + 60, yt); //handle left
FilledRectangle(xt + 50, yt - 30, xt + 100, yt - 20); //handle top
FilledRectangle(xt + 100, yt - 30, xt + 90, yt); //handle right
gotoxy(xt + 75, yt + 50);
SetTextSize(2);
DrawCenteredText(boxnum); //box number
}
void Suitcase::openbox()
{
paint();
for (int i = 0; i < 100; i++)
{
SetFillColor(RGB(96, 96, 96));
FilledRectangle(xt, yt, xt + 150, yt + 100);
SetFillColor(RGB(102, 51, 0));
FilledRectangle(xt + 50, yt - 30, xt + 60, yt);
FilledRectangle(xt + 50, yt - 30, xt + 100, yt - 20);
FilledRectangle(xt + 100, yt - 30, xt + 90, yt);
SetFillColor(RGB(0, 0, 0));
FilledRectangle(xt, yt, xt + 150, yt + i);
if (i >= 50)
{
gotoxy(xt + 75, yt + 50);
SetTextSize(2);
DrawCenteredText(/*formatcash*/(monval));
}
else
{
gotoxy(xt + 75, yt + 50);
SetTextSize(2);
DrawCenteredText(boxnum);
}
wait(0.01);
}
open = true;
}
int Suitcase::boxacc()
{
return boxnum;
}
bool Suitcase::opacc()
{
return open;
}
class Panel
{
private:
int value, xp, yp;
bool lit;
public:
Panel();
Panel(int value, int xp, int yp);
void unlight();
void draw();
int valacc();
};
Panel::Panel()
:value(0), xp(0), yp(0), lit(false)
{
}
Panel::Panel(int value_, int xp_, int yp_)
:value(value_), xp(xp_), yp(yp_), lit(true)
{
}
void Panel::unlight()
{
lit = false;
}
void Panel::draw()
{
if (lit)
{
SetColor(RGB(0, 0, 0));
SetFillColor(YELLOW);
FilledRectangle(xp, yp, xp + 100, yp + 20);
gotoxy((xp + 100) / 2, yp + 15);
SetTextSize(2);
DrawCenteredText(/*formatcash*/(value));
}
else
{
SetColor(RGB(0, 0, 0));
Rectangle(xp, yp, xp + 100, yp + 20);
gotoxy((xp + 100) / 2, yp + 15);
SetTextSize(2);
DrawCenteredText(/*formatcash*/(value));
}
}
int Panel::valacc()
{
return value;
}
class gameplay
{
private:
vector <Suitcase> cases;
vector <Panel> panels;
int x, y;
public:
gameplay();
gameplay(int x, int y);
void play();
void back();
};
gameplay::gameplay()
:cases(0), panels(0), x(0), y(0)
{
}
gameplay::gameplay(int x_, int y_)
:panels(26), x(x_), y(y_)
{
vector <String> models(26);
vector <double> monvals(26);
vector <int> relvals(26);
vector <Suitcase> tempcase(26);
randomize();
models[0] = "Ann McCabe";
models[1] = "Lisa McCabe";
models[2] = "Maya McCabe";
models[3] = "Legs McCabe";
models[4] = "Alanna McCabe";
models[5] = "Colleen McCabe";
models[6] = "Caoimhe McCabe";
models[7] = "Eva McCabe";
models[8] = "Ciaran McCabe";
models[9] = "Brianna McCabe";
models[10] = "Bridget McCabe";
models[11] = "Caitlin McCabe";
models[12] = "Naimh McCabe";
models[13] = "Cara McCabe";
models[14] = "Fianna McCabe";
models[15] = "Maggie McCabe";
models[16] = "Darcy McCabe";
models[17] = "Deirdre McCabe";
models[18] = "Eitna McCabe";
models[19] = "Enda McCabe";
models[20] = "Claire McCabe";
models[21] = "Fiona McCabe";
models[22] = "Gael McCabe";
models[23] = "Iona McCabe";
models[24] = "Mona McCabe";
models[25] = "Nessie McCabe";
monvals[0] = .01;
monvals[1] = 1;
monvals[2] = 5;
monvals[3] = 10;
monvals[4] = 25;
monvals[5] = 50;
monvals[6] = 75;
monvals[7] = 100;
monvals[8] = 200;
monvals[9] = 300;
monvals[10] = 400;
monvals[11] = 500;
monvals[12] = 750;
monvals[13] = 1000;
monvals[14] = 5000;
monvals[15] = 10000;
monvals[16] = 25000;
monvals[17] = 50000;
monvals[18] = 75000;
monvals[19] = 100000;
monvals[20] = 200000;
monvals[21] = 300000;
monvals[22] = 400000;
monvals[23] = 500000;
monvals[24] = 750000;
monvals[25] = 1000000;
int panelX = 50;
int panelY = 60;
for (int i = 0; i < panels.length(); i++)
{
panels[i] = Panel(monvals[i], panelX, panelY);
panelY+=27;
}
int r;
for(int i = 0; i < 26; i++)
{
do
{
r = random(26);
if (monvals[r] != -1)
{
relvals[i] = monvals[r];
monvals[r] = -1;
}
}
while(monvals[r] != -1);
}
int x__ = 400;
int y__ = 60;
for (int u = 0; u < tempcase.length(); u++)
{
tempcase[u] = Suitcase(u + 1, relvals[u], x__, y__, models[u]);
x__+=200;
if (x__>1250)
{
x__=400;
y__+=130;
}
}
cases = tempcase;
}
void gameplay::back()
{
SetFillColor(YELLOW);
FilledRectangle(0,0,GetMaxX(),GetMaxY());
SetFillColor(ORANGE);
FilledRectangle(0,0,300,GetMaxY());//LEFT PANEL
SetFillColor(WHITE);
FilledRectangle(600,GetMaxY()-200,GetMaxX()-100,GetMaxY());//BOTTOM PANEL
}
void gameplay::play()
{
back();
for (int i = 0; i < cases.length(); i++)
{
if (!cases[i].opacc())
{
cases[i].paint();
}
panels[i].draw();
}
for (int k = 0; k < cases.length(); k++)
{
if (cases[k].isHit(x,y))
{
MessageBox("","meme");
panels[k].unlight();
cases[k].openbox();
panels[k].draw();
}
}
}
class GuiClass
{
public:
GuiClass();
void GuiMouseClick(int x, int y); // Action if mouse click
void GuiPaint(); // Repaint the entire window
String Title();
private:
gameplay game;
int x, y;
};
GuiClass::GuiClass()
:game(x ,y)
{
}
String GuiClass::Title()
{
return "Deal or No Deal";
}
void GuiClass::GuiMouseClick(int x_, int y_)
{
x = x_, y = y_;
}
void GuiClass::GuiPaint()
{
game.play();
}
#include <lvp\gui_bot.h>