-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
123 lines (116 loc) · 3.57 KB
/
main.c
File metadata and controls
123 lines (116 loc) · 3.57 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
//#include <mf.h>
#include <time.h>
#include "mapeditor.h"
#include "game.h"
#define endl getCursorXY(&x,&y);gotoxy(x-3,y+1);
#define color(f_c,b_c) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),f_c | b_c<<4);
#define ps printf(" ");
#define def_color SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0x07);
/*const int source=1,split=14,wall=8,normal=6; // source: Blue split:Yellow wall: Gray normal:Ajori
int x,y,cell_num,walls;
const int width,height;
enum select_{selected=13}; //Selected: Pink
typedef struct{
int energy;
int type;
}block;
typedef struct{
int w,h;
}position;
typedef struct{
position p;
int energy;
}cell_inf;
*/
const int source=1,split=14,wall=8,normal=6; // source: Blue split:Yellow wall: Gray normal:Ajori
int x,y,cell_num,walls;
const int width,height;
// H
int main(void)
{
FILE *f;
while(1){
srand(time(NULL));
system("cls");
printf("[1] Load\n[2] New Single player game\n[3] New Multi player game\n[4] Map editor\n[5] Exit\n");
int q;
char *s;
char qwerty[50];scanf("%s",qwerty);q=atoi(qwerty);
system("cls");
if(q==1){
s=show_text_box("Enter file name to load:");
if(strstr(s,".bin")){
f=fopen(s,"rb");
if(f==NULL){
gotoxy(0,0);
show_box_end("Cant open file");Sleep(1500);
}
else{
cell_inf *cell_arr=(cell_inf*)malloc(sizeof(cell_inf));
fread(&width,sizeof(int),1,f);
fread(&height,sizeof(int),1,f);
block arr_map[height][width];
map(arr_map,f);
cell_load(cell_arr,f);
play(cell_arr,arr_map);
free(cell_arr);
}
fclose(f);
}
else if(strstr(s,".txt")){
f=fopen(s,"r");
if(f==NULL){
gotoxy(0,0);
show_box_end("Cant open file");Sleep(1500);
}
else{
cell_inf *cell_arr=(cell_inf*)malloc(sizeof(cell_inf));
fscanf(f,"Map:\nWidth:%d Height:%d\n",&width,&height);
block arr_map[height][width];
load_text(arr_map,&cell_arr,s,f);
play(cell_arr,arr_map);
free(cell_arr);
}
fclose(f);
}
else{
gotoxy(0,0);
show_box_end("Can`t open file!!\t:(");Sleep(1500);
}
}
else if(q==2){
s=show_text_box("Enter Map file name(just 'bin' files):");
f=fopen(s,"rb");
if(f==NULL){
show_box_end("Cant open file");Sleep(1500);
}
else{
cell_inf *cell_arr=(cell_inf*)malloc(sizeof(cell_inf));
fread(&width,sizeof(int),1,f);
fread(&height,sizeof(int),1,f);
block arr_map[height][width];
map(arr_map,f);
fclose(f);
insert_cell(cell_arr,arr_map);
play(cell_arr,arr_map);
free(cell_arr);
}
}
else if(q==3){
}
else if(q==4)
create_map();
else if(q==5){
system("cls");
show_box_end("Have a nice day!!\t:-p");
Sleep(2000);
exit(1);
}
free(s);
}
gotoxy(0,60);
return 0;
}