xTetris-Game
Loading...
Searching...
No Matches
xTetris.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <locale.h>
3#include <stdlib.h>
4
5#include "common.h"
6#include "definitions.h"
7#include "gameMenu.h"
8#include "gameCtrl.h"
9
10
14int main (int argc, char *argv[]) {
15
16 int nChoices[2][4];
17 int menu, opt, key=RESET;
18
19 setlocale(LC_CTYPE, "");
20
21 do{
22 welcome();
23 key = waitUserInput();
24 }
25 while(key!=CARRIAGE_RETURN);
26
27 nChoices[0][0]=2; /* Menu #1 -> Start Menu */
28 nChoices[1][0]=5;
29 nChoices[0][1]=6; /* Menu #2 -> Start Game */
30 nChoices[1][1]=8;
31 nChoices[0][2]=nChoices[1][2]=9; /* Menu #3 -> Rules */
32 nChoices[0][3]=nChoices[1][3]=10; /* Menu #4 -> Credits */
33 menu=1;
34
35 do{
36 if(menu!=6 && menu!=7){
37 if(menu>=8 && menu<=10){
38 opt=menu-6;
39 menu=1;
40 }
41 else
42 opt=nChoices[0][menu-1];
43 menu = choiceCtrl(menu, opt, nChoices[0][menu-1], nChoices[1][menu-1]);
44 }
45 else{
46
47 startGame(menu-6);
48 delayTimer(0);
49 menu=1;
50 key=RESET;
51 }
52 }
53 while(menu!=5);
54
55 goodbye();
56
57 clearCLI();
58 return 0;
59}
60
void delayTimer(int time)
Call the system sleep.
Definition common.c:41
int waitUserInput(void)
Loop until user press a valid key.
Definition common.c:130
void clearCLI(void)
Call the system function to clear the cli.
Definition common.c:25
#define CARRIAGE_RETURN
Definition definitions.h:20
#define RESET
Definition definitions.h:22
void startGame(int mode)
Start the gameplay.
Definition gameCtrl.c:224
void goodbye(void)
Print the end screen.
Definition gameMenu.c:35
void welcome(void)
Print the intro screen.
Definition gameMenu.c:12
int choiceCtrl(int menu, int opt, int min, int max)
Create the board.
Definition gameMenu.c:126
int main(int argc, char *argv[])
Main entry point of the program.
Definition xTetris.c:14