-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.c
80 lines (68 loc) · 1.34 KB
/
game.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* Date: 4/04/21
Main Game file which would run the game
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "snake_and_ladder.h"
#include "board.h"
void display();
void how_to_play();
int main()
{
int menu=0;
while (menu != 1)
{
//start cover title of the game
display();
scanf("%d", &menu);
printf("\n");
//take user input whether to play or know how to play
if (menu == 3)
{
return 0;
}
else if(menu == 2)
{
how_to_play();
}
else
{
display_userlogin();
}
}
}
//cover title start game and how to play
void display()
{
//print cover title
printf("\n");
printf("================================\n");
printf(" SNAKE_AND_LADDER \n");
printf("================================\n");
printf("\n");
printf("MENU :\n");
printf("1. Start\n");
printf("2. How to play\n");
printf("3. Exit\n");
printf("\nEnter Input: ");
}
void how_to_play()
{
FILE *file_pointer;
char s;
file_pointer = fopen("HELP.txt", "r");
if (file_pointer == NULL)
{
printf("\nCAN NOT OPEN FILE");
exit(0);
}
s = getc(file_pointer);
while (s != EOF)
{
printf("%c", s);
s = getc(file_pointer);
}
printf("\n");
fclose(file_pointer);
}