-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
93 lines (78 loc) · 1.72 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
/***************************
Author: Kyle Lanmon
Date: 2014-04-22
-commented out undefined functions
-added start screen
Date: 2014-04-23
-added drawCar, drawLog, drawFrog
-created Frog class
Date: 2014-04-29
-redesign. made classes for everything
-fix frog move bug
-created win zones
Date: 2014-04-30
-fixed win zone bug
Date: 2014-05-26
-make cars/logs move
TODO
-handle collision
-show number of lives
****************************/
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include "World.h"
#include "plotter.h"
using namespace std;
int main()
{
int random;
srand(time(NULL));
World game;
try{
game.setup();
}catch(char const* x){
cout << x;
return 1;
}
//wait for spacebar to be pressed
char ch;
do
{
ch = _getch();
}while(ch != ' ');
system("CLS");
game.drawWorld();
game.f.drawFrog(game.f.getColor());
while( ch != 'q' && ch != 'Q' && game.f.getWinCount() != 5 && game.f.getNumLives() > 0)
{
if( _kbhit() )
{
ch = _getch();
game.update(ch);
}
else
{
game.f.drawFrog(game.f.getColor());
random = rand() % 5 + 1;
for( int i = 0; i < random; i++ )
{
//random = rand() % 5 + 1;
game.r.logs[i].drawLog(i);
//random = rand() % 5 + 1;
game.s.cars[i].drawCar(i);
}
}
}
if( ch == 'q' || ch == 'Q' )
{
game.f.setNumLives(-1);
}
try{
game.quit(game.f.getNumLives());
}catch(char const* x){
cout << x;
}
return 0;
}