-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.cpp
76 lines (68 loc) · 1.24 KB
/
Source.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
#include <iostream>
#include <conio.h>
// main file
using namespace std;
extern bool gameOver, toJump;
void setup()
{
gameOver = false;
toJump = false;
cout << "Press space to jump and avoid the obstacles\n";
cout << "Now Press Enter to Start.\n";
_getch();
system("cls");
return;
}
void obstacle(int x, int i)
{
if (x == 0)
if (i == 2)
printf("<");
else
printf(" ");
else if (x == 1)
if (i == 3)
printf("<");
else
printf(" ");
else if (x == 2)
if (i == 3)
printf("#");
else
printf(" ");
else
printf("#");
}
void isSafe(int y, int* objx, int* objtype)
{
if (10 == objx[0])
{
if ((objtype[0] == 0) && (y == 2))
gameOver = true;
else if (objtype[0] == 1 && y == 3)
gameOver = true;
else if (objtype[0] == 2 && y == 3)
gameOver = true;
else if (objtype[0] == 3 && y > 1)
gameOver = true;
}
else if (10 == objx[1])
{
if (objtype[1] == 0 && y == 2)
gameOver = true;
else if (objtype[1] == 1 && y == 3)
gameOver = true;
else if (objtype[1] == 2 && y == 3)
gameOver = true;
else if (objtype[1] == 3 && y > 1)
gameOver = true;
}
}
void input()
{
while (!gameOver)
{
_getch();
toJump = true;
}
}