xTetris-Game
Loading...
Searching...
No Matches
src
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
14
int
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
delayTimer
void delayTimer(int time)
Call the system sleep.
Definition
common.c:41
waitUserInput
int waitUserInput(void)
Loop until user press a valid key.
Definition
common.c:130
clearCLI
void clearCLI(void)
Call the system function to clear the cli.
Definition
common.c:25
common.h
definitions.h
CARRIAGE_RETURN
#define CARRIAGE_RETURN
Definition
definitions.h:20
RESET
#define RESET
Definition
definitions.h:22
startGame
void startGame(int mode)
Start the gameplay.
Definition
gameCtrl.c:224
gameCtrl.h
goodbye
void goodbye(void)
Print the end screen.
Definition
gameMenu.c:35
welcome
void welcome(void)
Print the intro screen.
Definition
gameMenu.c:12
choiceCtrl
int choiceCtrl(int menu, int opt, int min, int max)
Create the board.
Definition
gameMenu.c:126
gameMenu.h
main
int main(int argc, char *argv[])
Main entry point of the program.
Definition
xTetris.c:14
Generated by
1.10.0