-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.c
More file actions
45 lines (40 loc) · 1.03 KB
/
run.c
File metadata and controls
45 lines (40 loc) · 1.03 KB
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
//
// Created by Aref on 19/07/01.
//
#include <time.h>
#include <stdlib.h>
#include "run.h"
#include "move.h"
#include "etc.h"
int run_game(Game *game) {
clock_t start_frame = clock();
game->time.start_game = clock();
while (clock() - game->time.start_game <= game->time.game_length){
getkey(game);
if(clock() - start_frame >= game->time.frame_length){
db(frame);
next_frame(game);
display(game);
db(display);
if(game->game_over) {
db(over);
end_game(game);
game = NULL;
break;
}
start_frame = clock();
display_point(game->player.point);
display_point(game->player.move_dir.move);
printf("exit: %c\n", game->rule->exit);
}
}
if(game == NULL)
return 1;
end_game(game);
return 1;
}
void display(Game *game) {
system("@cls||clear");
printf("Score: %d\n", game->score);
display_map(game->map);
}