-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmalloc_melee.c
More file actions
57 lines (49 loc) · 1.31 KB
/
malloc_melee.c
File metadata and controls
57 lines (49 loc) · 1.31 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
53
54
55
56
57
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include "./engine/player.h"
#include "./engine/util.h"
#include "./locations/floor_1/prison.h"
#include "./engine/save_system.h"
#include "./engine/main_menu.h"
#include "./engine/choice.h"
int main()
{
srand(time(NULL));
Player player;
/* display main menu */
display_main_menu();
/* get user input */
Choice options[3] = {
{ 1, "New Game" },
{ 2, "Load Game" },
{ 3, "Exit" }
};
short choice = choose(options, 3);
if (choice == 1) {
/* Ask for player name first */
printf("Enter your name: ");
char name[50];
fgets(name, 50, stdin);
name[strlen(name) - 1] = '\0'; // Remove newline character
player = createPlayer(name);
player.current_location = &firstCell;
} else if (choice == 2) {
/* get name of player */
char save[50];
printf("Enter your save: ");
fgets(save, 50, stdin);
save[strlen(save) - 1] = '\0'; // Remove newline character
player = *load_game(save);
} else {
return 0;
}
while(player.current_location != NULL)
{
clearScreen();
(*player.current_location)(&player);
}
printf("\n");
promptToPressEnter("end the game");
return 0;
}