-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
74 lines (65 loc) · 1.48 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
#include "Jeu.h"
int main()
{
srand(time(NULL));
bool ech(false);
char touche;
int score(0);
Snake serp;
Terrain field(35, 60);
field.afficher();
do
{
Sleep(50);
if(_kbhit())
{
touche =_getch();
switch(touche)
{
case '5':
{
if(serp.getWay() != HAUT)
serp.setWay(direction::BAS);
break;
}
case '8':
{
if(serp.getWay() != BAS)
serp.setWay(direction::HAUT);
break;
}
case '4':
{
if(serp.getWay() != DROITE)
serp.setWay(direction::GAUCHE);
break;
}
case '6':
{
if(serp.getWay() != GAUCHE)
serp.setWay(direction::DROITE);
break;
}
case 27:
{
ech = true;
break;
}
}
}
serp.dep();
field.afficherS(serp);
field.afficherP();
if(field.manger(serp))
{
score++;
gotoligcol(2,65);
Color(11,0);
std::cout << "Score : " << score;
Color(15,0);
serp.add();
field.genererPomme();
}
}while(!field.out(serp) && !serp.touch() && !ech);
return 0;
}