-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
49 lines (47 loc) · 1.09 KB
/
main.c
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
#include <signal.h>
#include <time.h>
#include <render.h>
#include <workField.h>
int main(){
signal(SIGINT, exitRetur);
srand(time(NULL));
const int LEN = 4;
bool game = true;
int** field = NULL;
creatField(&field, LEN);
beginGame(LEN * 4 + LEN + 1);
int sum = 0, max = 2;
while (game){
bool motion = false;
if (wingGame(field, LEN, &max)){
printBarEnd(max, sum, LEN);
freeField(field, LEN);
if (exitOrRestart())
exitRetur(0);
creatField(&field, LEN);
sum = 0;
max = 2;
repeat(CLEAR, LEN + 1);
}
printBar(max, sum, LEN);
printField(field, LEN);
do{
char symbol = input();
if (upperrcase(symbol) == 'A')
motion = shiftsLeft(field, LEN, &sum);
else if (upperrcase(symbol) == 'D')
motion = shiftsRight(field, LEN, &sum);
else if (upperrcase(symbol) == 'W')
motion = shiftsUp(field, LEN, &sum);
else if (upperrcase(symbol) == 'S')
motion = shiftsDown(field, LEN, &sum);
else if (symbol == 'q'){
freeField(field, LEN);
exitRetur(0);
}
}while(!motion);
locatRand(field, LEN);
repeat(CLEAR, LEN + LEN + LEN);
}
return 0;
}