-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
62 lines (40 loc) · 1.21 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
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
#include <stdlib.h>
#include "main.h"
#include "printBoard.h"
#include "moves.h"
#include "constants.h"
#include "setup.h"
int main(int argc, char* argv[]) {
/* Validate Inputs */
int rows, columns;
if (validateInputs(&rows, &columns, &argc, argv)) {
/* Initialise Map */
vector2d playerPosition = {0, 0};
int roadCount = rows / 2;
int gameStatus = PLAYING;
int* carPositions = malloc(sizeof(int) * roadCount);
int* carDirections = malloc(sizeof(int) * roadCount);
initialiseCars(carPositions, carDirections, roadCount, columns);
/* Loop until win or lose */
/* Print board */
/* Get input */
/* Update board and check win/loss */
system("clear");
while (gameStatus == PLAYING)
{
gameStatus = makeMove( rows, columns, roadCount, &playerPosition, carPositions, carDirections);
}
printBoard(rows, columns, playerPosition, carPositions, carDirections);
/* Handle Win and Lose */
if (gameStatus == WIN) {
printf("You Win\n");
} else if (gameStatus == LOSE) {
printf("You Lose\n");
}
/* End Game */
free(carPositions);
free(carDirections);
}
return 0;
}