-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (42 loc) · 1.05 KB
/
Copy pathmain.cpp
File metadata and controls
52 lines (42 loc) · 1.05 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
46
47
48
49
50
51
52
#include <stdio.h>
#include <stdlib.h>
#include "game.h"
#include "video.h"
int displayWinner();
int Argv; char** Args;
/*prgm N nbrow nbline xscreen yscreen human0? human1? redplayer0? */
int main(int argv, char** args)
{
Argv = argv;
Args=args;
initgame();
initvideo();//video is init after game parameters have been established
printgrid();
while(1){
if(IsGridFull(G)){G.playerturn=-1;/*to notify a draw game*/break;}
int row=AskPlayerRow();
AddTokentoGrid(row,G.players[G.playerturn].arms,&G);
SDL_Delay(10);
PrintLastToken(row);
if(lastwin(row,G)!=TOKEN(EMPTY))
{
displayWinner();
break;
}
NextTurn(&G);
}
SDL_Event e;
while (1)
{
SDL_PollEvent(&e);
if (e.type == SDL_KEYDOWN)
if(e.key.keysym.sym==SDLK_ESCAPE)
break;
if (e.type == SDL_QUIT)
break;
}
SDL_DestroyRenderer(V.renderer);
SDL_DestroyWindow(V.window);
atexit(SDL_Quit);
return G.playerturn; //return which player has won -1 for draw
}