Ballin

Check-in [7aad388870]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:copied code from end of spring 2010
Timelines: family | trunk | stable
Files: files | file ages | folders
SHA1:7aad3888700bfc804300d3777f36909e79a0c0a9
User & Date: donnyjward@gmail.com 2010-06-01 07:36:30
Context
2010-06-01
07:36
copied code from end of spring 2010 Leaf check-in: 7aad388870 user: donnyjward@gmail.com tags: trunk, stable
Changes
Hide Diffs Unified Diffs Ignore Whitespace

Added Makefile.

























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#SOURCES=main.c input.c p_bman.c map.c
#OBJECTS=main.o input.o p_bman.o map.o

all: bomberman

#bomberman: $(OBJECTS)

#$(OBJECTS): 
bomberman: main.o input.o p_bman.o map.o enemy.o
	gcc main.o input.o p_bman.o map.o enemy.o -lcurses -lpthread -g -o bomberman

main.o: main.c
	gcc -c main.c

input.o: input.c
	gcc -c input.c
p_bman.o: p_bman.c
	gcc -c p_bman.c
map.o: map.c
	gcc -c map.c
enemy.o: enemy.c
	gcc -c enemy.c


clean:
	-rm *.o bomberman


Added enemy.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
#include "enemy.h"
#include "p_bman.h"
#include "map.h"
#include <math.h> //for absolute value abs()

#define LIST_SIZE 100
#define MOVE_COST 10

extern map * maps;
extern space * spaces;
extern bomberman* b;
extern lvlOver;

enemy * enemys[MAX_ENEMIES]; //array of pointers to enemies. an actor is an individual enemy
int num_enemys_total;
int num_enemys_alive;

extern bomberman * b;

space * openlist[LIST_SIZE]; //array of pointers to spaces
space * closedlist[LIST_SIZE];
int openlist_count = 0; //start empty
int closedlist_count = 0;

void e_alloc(enemy ** e)
{
	//allocate space for structure enemy
	enemy *temp = ((enemy *)malloc(sizeof(enemy)));
	*e = temp;
	//set default values
	(*e)->alive = 1;
	(*e)->fire = 1;
	(*e)->bomb = 1;
	(*e)->bombs_set = 0;
	(*e)->cpu = 1;
	(*e)->wins = 0;
	(*e)->symbol = '@'; //what is displayed for this character
	
	(*e)->spiky = 1; //if it is spiky then anybody it touches dies
	(*e)->thinkstate = 0;
}

void e_list_init(space * list[])
{
	int i;
	for (i = 0; i < LIST_SIZE; i++)
	{
		openlist[i] = NULL;
		closedlist[i] = NULL;
	}
}

void e_setpos(enemy * actor, int index)
{
	actor->pp = index;
}

int e_getpos(enemy * actor)
{
	return actor->pp;
}

enemy * e_getenemyatpos(int pos)
{
	enemy * temp = NULL;
	int i;

	for (i = 0; i < num_enemys_total; i++)
	{
		if ( enemys[i]->pp == pos ) //this actor is at this position
			return enemys[i]; //a pointer to the enemy
	}

	return temp;
}

//flag this enemy as dead
void e_kill(enemy * actor)
{
	int pos = e_getpos(actor);
	//num_enemys_alive--;
	actor->alive = 0;

	//erase him from the space hes on.
	spaces[pos].is_enemy = 0;
	spaces[pos].icon = none;
}

void e_clear()
{
	int i;

	for (i = 0; i < num_enemys_total; i++)
	{
		enemys[i]->alive = 0;
		free(enemys[i]);
	}

	num_enemys_total = 0;
	num_enemys_alive = 0;
}
	
void e_think()
{
	//current behavior: move toward the player, most of the time at least, until a better algorithm is implemented
	int i, j;

	int b_pos = bm_getpos(b);
	int e_pos;
	int dist;
	int dir;
	int trymove;

	for (i = 0; i < num_enemys_total; i++) //cycle through enemys
	{
		if (!(enemys[i]->alive))
		{
			//cant think if im dead
		}
		else
		{
			e_pos = e_getpos(enemys[i]);
			dist = abs(b_pos - e_pos);

			if (b_pos < e_pos) //going to move up or left
			{
				if ( dist > maps->sizex ) //pretty far away, move up
				{
					//move up
					dir = dir_up;
				}
				else //just move left for now
				{
					//move left
					dir = dir_left;
				}
			}
			else //going to move down or right
			{
				if ( dist > maps->sizex ) //pretty far, move down
				{
					//move down
					dir = dir_down;
				}
				else //just move right for now
				{
					//move right
					dir = dir_right;
				}
			}

			//i know where im going, now see if i can actually move there
			trymove = e_trymove(enemys[i], dir);
			
			if (!trymove) //couldnt move where i wanted to, just try to move somwhere now, anywhere
			{
				for (j = 0; j < num_enemys_total; j++)
				{
					trymove = e_trymove(enemys[i], j); //just try to move anydirection
					if (trymove) //suceessfully moved
						break;
				}
			}
		}
	}

}

int e_trymove(enemy * actor, int dir)
{
	int success = 0;
	if(actor->alive != 0){
		
	
	if(dir == dir_right)
	{
		actor->pp++;
			
		if(mp_checkspace(actor->pp, has_hard) == 1)
			actor->pp--;
		else if(mp_checkspace(actor->pp, has_soft) == 1)
			actor->pp--;
		else if (mp_checkspace(actor->pp, has_bomb) == 1) //cant move thru bombs
			actor->pp--;
		else if (mp_checkspace(actor->pp, has_enemy) == 1) //cant move thru enemys
			actor->pp--;
		else if (mp_checkspace (actor->pp, has_xplode) == 1){ //bomb explosion, dead
			e_kill(actor);
			spaces[actor->pp-1].icon = none;
			spaces[actor->pp-1].is_enemy = 0;
			spaces[actor->pp].icon = XPLODE;
		}	
		else if(actor->alive != 0){ //i can and will move now
			//move symbol to next space, clear old space, and also update is_enemy values
			spaces[actor->pp].icon = actor->symbol;
			spaces[actor->pp].is_enemy = 1;
			if(spaces[actor->pp].is_bman == 1)
				bm_kill(b);
			spaces[actor->pp-1].icon = none;
			spaces[actor->pp-1].is_enemy = 0; 

			success = 1;
		}
	}
	else if(dir == dir_left)
	{
		actor->pp--;
		if(mp_checkspace(actor->pp, has_hard) == 1)
			actor->pp++; //undo decrement due to wall present
		else if(mp_checkspace(actor->pp, has_soft) == 1)
			actor->pp++; //undo decrement due to soft wall
		else if (mp_checkspace(actor->pp, has_bomb) == 1) //cant move thru bombs
			actor->pp++;
		else if (mp_checkspace(actor->pp, has_enemy) == 1) //cant move thru enemys
			actor->pp++;

		else if (mp_checkspace (actor->pp, has_xplode) == 1){ //bomb explosion, dead
			e_kill(actor);
			spaces[actor->pp+1].icon = none;
			spaces[actor->pp+1].is_enemy = 0;
			spaces[actor->pp].icon = XPLODE;
		}
		else if(actor->alive != 0){
			spaces[actor->pp].icon = actor->symbol;
			spaces[actor->pp].is_enemy = 1;
			if(spaces[actor->pp].is_bman == 1)
				bm_kill(b);
			spaces[actor->pp+1].icon = none;
			spaces[actor->pp+1].is_enemy = 0; 

			success = 1;
		}
	}
	else if(dir == dir_down)
	{
	
		actor->pp += maps->sizey;
		if(mp_checkspace(actor->pp, has_hard) == 1)
			actor->pp -= maps->sizey; //undo increment due to wall present
		else if(mp_checkspace(actor->pp, has_soft) == 1)
			actor->pp -= maps->sizey; //undo increment due to soft wall
		else if (mp_checkspace(actor->pp, has_bomb) == 1) //cant move thru bombs
			actor->pp -= maps->sizey;
		else if (mp_checkspace(actor->pp, has_enemy) == 1) //cant move thru enemys
			actor->pp -= maps->sizey;
		else if (mp_checkspace (actor->pp, has_xplode) == 1){ //bomb explosion, dead
			e_kill(actor);
			spaces[actor->pp-maps->sizey].icon = none;
			spaces[actor->pp-maps->sizey].is_enemy = 0;
			spaces[actor->pp].icon = XPLODE;
		}
		else if(actor->alive != 0){
			spaces[actor->pp].icon = actor->symbol;
			spaces[actor->pp].is_enemy = 1;
			if(spaces[actor->pp].is_bman == 1)
				bm_kill(b);
			spaces[actor->pp-maps->sizey].icon = none;
			spaces[actor->pp-maps->sizey].is_enemy = 0; 

			success = 1;
		}
	}
	else if(dir == dir_up)
	{
		actor->pp -= maps->sizey;
		if(mp_checkspace(actor->pp, has_hard) == 1)
			actor->pp += maps->sizey; //undo decrement due to wall present
		else if(mp_checkspace(actor->pp, has_soft) == 1)
			actor->pp += maps->sizey; //undo decrement due to wall present
		else if (mp_checkspace(actor->pp, has_bomb) == 1) //cant move thru bombs
			actor->pp += maps->sizey;
		else if (mp_checkspace(actor->pp, has_enemy) == 1) //cant move thru enemys
			actor->pp += maps->sizey;
		else if (mp_checkspace (actor->pp, has_xplode) == 1){ //bomb explosion, dead
			e_kill(actor);
			spaces[actor->pp+maps->sizey].icon = none;
			spaces[actor->pp+maps->sizey].is_enemy = 0;
			spaces[actor->pp].icon = XPLODE;
		}

		else if(actor->alive != 0)
		{
			spaces[actor->pp].icon = actor->symbol;
			spaces[actor->pp].is_enemy = 1;
			if(spaces[actor->pp].is_bman == 1)
				bm_kill(b);
			spaces[actor->pp+maps->sizey].icon = none;
			spaces[actor->pp+maps->sizey].is_enemy = 0; 

			success = 1;
		}
	}
	return success;
	}
	else
		return 0;
}

void e_list_add(space * list[], space * s, int * count)
{
	int i = 0;

	while (list[i] != NULL) //go to end of list where nothing is there
	{
		if (i >= LIST_SIZE)
			return;
		i++;
	}

	list[i] = s;
	*count++;
}

void e_list_remove(space * list[], space * s, int * count)
{
	int i = 0;

	while (list[i] != s) //go through list until end reached or s found
	{
		if (i >= LIST_SIZE)
			return;
		i++;
	}

	//s found, bump up each element and decrement count
	*count--;

	while (list[i] != NULL)
	{
		list[i] = list[i+1]; //go through rest of list and bump up every element

		
		i++;
		if (i >= LIST_SIZE-1) //if list is full, replace last element with null
		{
			list[i] = NULL;
		}
	}
}

int e_list_find(space * list[], space * s)
{
	int i = 0;

	while (i < LIST_SIZE)
	{
		if (list[i] == s) //found it
			return 1;
		i++;
	}

	return 0; //went thru whole list and found nothing
}

void e_list_sort(space * list[])
{

}

int e_getpath(enemy * actor)
{	
	int done = 0; //1 on finish(found path), 2 on finished(no path possible)
	int i, x1, y1, x2, y2, temp_int;
	int pos = e_getpos(actor);
	int pos_rel; //relativeposition of space
	int pos_end = bm_getpos(b); //target position (most likely bomberman pos)
	space * current = &(spaces[pos]); //the current square
	space * target = &(spaces[pos_end]); //target square
	space * s; //pointer to space


	e_list_add(openlist, current, &openlist_count); //add the starting space to open list

	while ( openlist_count ) //stop when the list is empty
	{
		e_list_sort(openlist); //sort the current list lowest f score 1st
		//switch this lowest f score space to the closed list
		current = openlist[0];
		e_list_remove(openlist, current, &openlist_count);
		e_list_add(openlist, current, &closedlist_count);

		if (current == target) //target added to closed list, finished.
			return 1;
		//scan the 4 adjacent squares to this current node
		for (i = 0; i < 4; i++) //search left, right, above, then below node
		{
			pos_rel = mp_getrelative(pos, i);
			s = &(spaces[pos_rel]);
			if ( !mp_walkable(pos_rel) || e_list_find(closedlist, s) )
			{
				//if not walkable space or on closed list, ignore it
			}
			else
			{
				if ( !e_list_find(openlist, s) ) //if not on open list,
				{ //then add it to open list, make current square the parent of this square, and calculate its f score
					e_list_add(openlist, s, &openlist_count);
					s->parent = current;

					//pos_rel is already the pos of this space
					mp_getcoords(pos_rel, &x1, &y1); //sets x and y to the coords of this space
					mp_getcoords(pos_end, &x2, &y2); //sets x and y to the coords of target

					s->g = s->parent->g + MOVE_COST; //add movecost to g of parent square
					s->h = MOVE_COST*(abs(x1-x2) + abs(y1-y2)); //number of moves to get to end
					s->f = s->g + s->h; //f = g+h
				}
				else //already on the open list wtf?
				{ //see if this node's g cost would b smaller if it went thru the current node instead of whatever its parent node is.
					temp_int = current->g + MOVE_COST;
					if (s->g > temp_int) //then this path is better, change its parent to current node and recalc its f, g cost
					{
						s->parent = current;
						s->g = temp_int;
						s->f = s->g + s->h;
					}
				}
			}

		}

	}
	
	return 0; //fail
}

Added enemy.h.



































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#ifndef __ENEMY_H__
#define __ENEMY_H__


#define MAX_ENEMIES 9

struct bomberman;
/*
below i use a function that takes arrays of structs. before you can use an array, the struct must be defined 
so the compiler knows how much space to set aside for it. thats why map.h must be included here, and simply
declaring map and space above doesnt work
*/
#include "map.h"

typedef struct enemy
{
	int alive; //similar to bool alive = false
	int fire; //blast radius of bombs
	int bomb; //# of bombs that can be live at once
	int bombs_set; //# of bombs currently live
	//int skull; //the type determines which skull powerdown the bomber has. use enum
	int cpu; //bool: whether or not to use ai control
	int wins;

	char symbol; //what is displayed for this character
	int pp; //enemy position
	
	int spiky; //if it is spiky then anybody it touches dies
	int thinkstate;
	
} enemy;

void e_alloc(enemy ** e);
void e_setpos(enemy * actor, int index); //set position of an enemy to index
int e_getpos(enemy * actor); //get space index that the enemy is standing on
enemy * e_getenemyatpos(int pos); //return a pointer to the enemy at a specific space
void e_kill(enemy * actor);
void e_clear(); //clear enemy array. use at the end of a round to reset. same as killing all enemies

void e_think(); //periodic function that makes all the decisions for enemy
int e_trymove(enemy * actor, int dir); //try to move in a direction. returns 1 on success, 0 on fail

void e_list_add(space * list[], space * s, int * count); //add a space to the end of an open or closed list
void e_list_remove(space * list[], space * s, int * count); //remove a space
int e_list_find(space * list[], space * s); //search for a specific space. 1 on success, 0 on fail
void e_list_sort(space * list[]); //sort list from smallest to largest f scores
int e_getpath(enemy * actor);

#endif

Added input.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
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
/*
==================================================
input.c (formerly move.c)
By: Julio Pescador
Edited By: Donny Ward

Description:

Currently creates and displays the gamespace and monitors keyboard input to update the screen. Map functionality needs to be
transferred to map.c file for more flexibility. ~check
==================================================
*/

#include <curses.h>
#include <string.h>
#include <stdlib.h>
#include "map.h"
#include "enemy.h"
#include "p_bman.h"

/*
push arrow keys to move
spacebar to set bombs
push k to kill yourself (ends match)
w = win button (advance to next level)
*/

extern map * maps;
extern enemy * enemys[MAX_ENEMIES];
extern space * spaces;
extern bomberman* b;


extern int num_enemys_total;
extern int num_enemys_alive;
extern int data;

int spacesize;
char player;
int lvlOver;
int success = 1;

void init_new_game()
{
	mp_alloc(&maps); //allocate some space for the MAP
	bm_alloc(&b); //allocate space for structure bomberman
	mp_readMapsInfo(); //read in array of txt file from maps.txt
}

void start_new()
{
	b->alive = 1; //set bomberman to alive when starting game!
	maps->iterate = 0; //iterate back to level when starting new
	mp_readMap(); //read in map level1.txt, level2.txt, etc

	spacesize = maps->sizex*maps->sizey;
	mp_s_alloc(&spaces, spacesize);

	mp_create();
	
	player = mp_getSymbol(); //get player symbol
	bm_setsymbol(player); //set player symbol
	mp_startPosition(); //place player starting position
}

int next_lvl()
{
	int success;
	free(maps->buffer);
	maps->iterate++;
	success = mp_readMap();

	if(success == 1){
	spacesize = maps->sizex*maps->sizey;
	mp_s_alloc(&spaces, spacesize);

	mp_create();
	
	player = mp_getSymbol(); //get player symbol
	bm_setsymbol(player); //set player symbol
	mp_startPosition(b); //place player starting position
	}

	return success; //local variable success, not global variable!!
}

int m_move()
{
	if(success) //success is from global variable declared at top of this c file
	        success = mp_playerInput(b); //must find out how to make enemy a global variable
	
	if ( !bm_isalive()) //if the player dies
	{
		clear();
		lvlOver = 1;
		return 0;
	}
	else if ( !num_enemys_alive ) //if all enemies are dead. MUST be else if. if you die with the last enemy then i win u lose
	{
		//next stage
		lvlOver = 1;
		clear();
		return 1;
	}
}

Added levels/lvl1.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|B                  |
| X X X X X X X X X |
|                   |
| X X X X X X X X X |
|                   |
| X X X X X X X X X |
|              @    |
| X X X X X X X X X |
|                   |
| X X X X X X X X X |
|         @         |
| X X X X X X X X X |
|    @              |
| X X X X X X X X X |
|                @  |
| X X X X X X X X X |
|  @                |
| X X X@X X X X X X |
|                  @|
---------------------

Added levels/lvl10.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|B                  |
| # # # # # # # # # |
|                   |
| # # # # # # # # # |
|                   |
| # # # # # # # # # |
|                   |
| # # # # # # # # # |
|              @    |
| # # # # # # # # # |
|          @        |
| # # # # # # # # # |
|     @             |
| # # # # # # # # # |
|                   |
| # # # # # # # # # |
|  @       @        |
| # # # # # # # # # |
|          @       @|
---------------------

Added levels/lvl11.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
| X       B       X |
| X XXX X#X#X XXX X |
| X   X   X   X   X |
| XXX X X X X X XXX |
| #               # |
| XXXXX X X X XXXXX |
|                   |
| X XXXXX X XXXXX X |
| X               X |
| X X XXXX#XXXX X X |
| X               X |
| X XXXXX X XXXXX X |
|  @             @  |
| XXXXX X X X XXXXX |
| #       X       # |
| XXX X X X X X XXX |
| X @ X       X @ X |
| X XXX X#X#X XXX X |
| X       @       X |
---------------------

Added levels/lvl12.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|B                  |
| XXXXX XXXXXXXXXXX |
| X X     X   X   X |
| # XXXXX X X X X # |
| X     X X  @  X X |
| X X X X X#X XXX X |
| X     X         X |
| X XXX XXXXX X X X |
| #   X         X X |
| X X X X X X XXX X |
| X X X   X  @X     |
| XXX XXX#X X X X X |
|         X   X   X |
| X XXXXXXX X XXX X |
| X X  @    X     X |
| # X#XXXXX#XXXXX # |
| X   X         X X |
| XXXXX XXXXXXXXX X |
|      @           @|
---------------------

Added levels/lvl13.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|       X B X       |
| X#XXXXX   XXXXX#X |
| X       X       X |
| X XXX XX#XX XXX X |
| X X           X X |
| X XXX X # X XXX X |
| #     X   X     # |
|XX XXX X X X XXX XX|
|   X   X   X   X   |
|   X XX# # #XX X   |
|   X   X   X   X   |
|XX XXX X X X XXX XX|
| #     X   X     # |
| X XXX X # X XXX X |
| X X           X X |
| X XXX XX#XX XXX X |
|@X       X       X@|
| X#XXXXX   XXXXX#X |
|    @  X @ X  @    |
---------------------

Added levels/lvl14.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
| X  B    X    X    |
| X X XXX X X X X XX|
|   X       X      X|
|#X X XXX XXX X XXX |
|       X X     X   |
|XXXX X X X X X XXX |
|   X      #        |
|XX XXX X X X X XXX |
|  @       X  X @  #|
| X X XXX X X X X X |
| #     X     X  X  |
| X X X X X XXX X X |
| X     X    @    X |
| X X XXX XXX XXX X |
|XX   X   X     X XX|
|#X XXX X X X X X X |
|   #     X    X    |
|XXXX X X X X X X X |
|    #X XXX   X  @X |
---------------------

Added levels/lvl15.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|B # #  X       X   |
|##X # #X XXXX   X##|
| X  XX      X   X  |
| #  X   X#   XX    |
| # X  XX  X      X |
| XXX      X   XX## |
|##  #X    XXX      |
|X  XX        X  XX |
|       XXX X   XX  |
| XXX  X  X  X XX   |
|   X  X   # X      |
|   X XX# #   XXX#  |
| ##     #X      # @|
|XX  XXX  X   X  XX |
|    X X  XXXX  X   |
|XXX##          X   |
|@X      X    X  @X |
|#X##  X XXX   X  ##|
| @ #X X   X   XXX @|
---------------------

Added levels/lvl16.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|X##X##X##X##X##X##X|
|#B #  #  #  #  #  #|
|#  #  #  #  #  #  #|
|X##X##X##X##X##X##X|
|#  #  #  #  #  #  #|
|#  #  #  #  #  #  #|
|X##X##X##X##X##X##X|
|#  #  #  #  #  #  #|
|#  #  #  #  #  #  #|
|X##X##X##X##X##X##X|
|#  #  #  #  #  #  #|
|#  #  #  #  #  #  #|
|X##X##X##X##X##X##X|
|#  #  #  #  #  #@ #|
|#  #  #  #  #  # @#|
|X##X##X##X##X##X##X|
|#  #  #  #  #@ #@@#|
|#  #  #  #  # @#@@#|
|X##X##X##X##X##X##X|
---------------------

Added levels/lvl17.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|B #  X      X  X   |
|#X XX  XXX  XX X   |
| X      X       X  |
|XX  XXX    XX    X |
| ##   X  X  X #X   |
|XX XX  X    XX X  X|
|#  X    ##X   XX  X|
|#X # XX   X    X  X|
|X X  X  @    XX  XX|
|     XX    X X#  @ |
|   X   #  XX #  X  |
| X XXX##X   X  X ##|
|#X      X   X  X   |
| XX XX    X  ##    |
| @ #  XX## X    X  |
|   X     ##  XXX # |
|X  X##  @ #       #|
| XXX ##X  X    X## |
| #    #XX X   X  @ |
---------------------

Added levels/lvl18.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|     #       #     |
|    X X     X X    |
|   X   X   X   X   |
|  X     X X     X  |
| #   B   #    @  # |
|  X     X X     X  |
|   X   X   X   X   |
|    X X     X X    |
|     #       #     |
|    X X     X X    |
|   X   X   X   X   |
|  X     X X     X  |
| #   @   #   @   # |
|  X     X X     X  |
|   X   X   X   X   |
|    X X     X X    |
|     #       #     |
|    X X     X X    |
|                   |
---------------------

Added levels/lvl19.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
| XXXXXXX X XXXXXXX |
| XB # X# X #X #  X |
| XXXX  X   X  XXXX |
| #   # # X # #   # |
| XXXXXXX X XXXXXXX |
| X # # X X X # # X |
| X X X X X X X X X |
| X XXXXX X XXXXX X |
| X #    # #    # X |
| # X X X X X X X # |
| X #    # #    # X |
| X XXXXX X XXXXX X |
| X X@X X X X X@X X |
| X # # X X X # # X |
| XXXXXXX X XXXXXXX |
| # @ # # X # # @ # |
| XXXX  X   X  XXXX |
| X @# X# X #X #@ X |
| XXXXXXX X XXXXXxX |
---------------------

Added levels/lvl2.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|                   |
| X X X X X X X X X |
| B X   X   X   X   |
| X X X X X X X X X |
| X   X   X   X   X |
| X X X X X X X X X |
|   X   X   X   X   |
| X X X X X X X X X |
| X   X @ X   X   X |
| X X X X X X X X X |
|   X   X   X @ X   |
| X X X X X X X X X |
| X@  X   X   X   X |
| X X X X X X X X X |
|   X   X @ X   X @ |
| X X X X X X X X X |
| X   X @ X   X   X |
| X X X X X X X X X |
|    @         @    |
---------------------

Added levels/lvl20.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|B         XXXXXXXX |
| XX#XXXXX X      X |
| X# #  #X X XXXX X |
|#X X XX X # X  X X |
| XXXXXX X X X XX # |
|#    @  # X X    X |
| XXXXXXXX X XXXXXX |
| X        X     X  |
| X  XXXXXXXXXXX X  |
| X  #   @   # X X  |
| X  X XXXXXX# X #  |
| X  X X # #  #X X  |
| X  X XXXXXXXXX XXX|
|    X   @  X       |
| X  X#XXXX X XXXXX |
| X  X X  # X X # X |
|##@   X  X # XXX X |
| XXXXXXXXX X  # @X |
|  #    #   XXXXXXX |
---------------------

Added levels/lvl21.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|B  X       XXXXX   |
|X  X X#XX     X   X|
| X XXX  X X X    X |
|X       XX # XXX ##|
|  XXX#X        #   |
|  #   X    XXX X XX|
|  XXX X  XXX X X X |
|    X XXXX   X X # |
|XX  X      XXX XXX |
| X##X  XXX X    @  |
|       X XXX X##XX |
|@  XXXXX     X   X |
|   #   @  XXXX XXX |
|   X XXX  X  @ X   |
|XX#X X X  X XX#X   |
|  @  X XXXX X      |
| X#XXX      #  XXX |
| #     X#XX XXXX # |
| XXXXXX  X      X @|
---------------------

Added levels/lvl22.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|XXXXXXXXXXXXXXXXXXX|
|XB  X   # #   X   X|
|XXX##   X X   ##XXX|
|X       X X       X|
|X#XXXXXXX XXXXXXX#X|
|X     #     #     X|
|X     X     X     X|
|X     X     X     X|
|X#XXXXX     XXXXX#X|
|X        X        X|
|X#XXXXX     XXXXX#X|
|X     X     X     X|
|X     X     X     X|
|X     #     #     X|
|X#XXXXXXX XXXXXXX#X|
|X     @ X X  @    X|
|XXX##   X@X   ##XXX|
|X@  X   # #   X  @X|
|XXXXXXXXXXXXXXXXXXX|
---------------------

Added levels/lvl23.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|XXXXXXXXXXXXXXXXXXX|
|X          B      X|
|XXXXXXXX XXXXXXX XX|
|       X X     X X |
|XXXXXXXX XXXXXXX XX|
|X                 X|
|XXXX XXXXXXXXX XXXX|
|   X X       X X   |
|XXXX XXXXXXXXX XXXX|
|X                 X|
|XX XXXXXXX XXXXXXXX|
| X X     X X       |
|XX XXXXXXX XXXXXXXX|
|X   @        @    X|
|XXXXXXXX XXXXXXXXXX|
|       X X         |
|XXXXXXXX XXXXXXXXXX|
|X   @     @       X|
|XXXXXXXXXXXXXXXXXXX|
---------------------

Added levels/lvl24.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|X##      B      ##X|
|X##X  X     X  X##X|
|X##X  #XXXXX#  X##X|
|X###X         X###X|
|X###X  XXXXX  X###X|
|X####X   X   X####X|
|XX####   X   ####XX|
|X#@##X       X###@X|
|X###X  X   X  X###X|
|X###  XXX XXX  ###X|
|X###X  X   X  X###X|
|X@###X       X####X|
|XX####   X   ####XX|
|X####X@  X  @X####X|
|X###X  XXXXX  X##@X|
|X###X         X###X|
|X##X  #XXXXX#  X##X|
|X##X  X     X  X##X|
|X##      @      ##X|
---------------------

Added levels/lvl25.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
| XX###XX    XX###XX|
| X     X    X     X|
|XX BX  XX##XX  X  X|
| X     X    X     X|
| XX###XX    XX###XX|
|                   |
|XX    XX###XX    XX|
| X    X     X    X |
| XX##XX  X  XX##XX |
| X    X     X    X |
|XX    XX###XX    XX|
|                   |
| XX###XX    XX###XX|
| X     X    X     X|
|XX @X  XX##XX  X@ X|
| X     X    X     X|
| XX###XX    XX###XX|
|  @       @     @  |
|XX   XX    XX    XX|
---------------------

Added levels/lvl3.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|                   |
| X X X X X X X X X |
|   X X     X X     |
| X X X X X X X X X |
| X  B  X X   X X   |
| X X X X X X X X X |
|   X X     X X  @  |
| X X X X X X X X X |
|       X X     X X |
| X X X X X X X X X |
| X X     X X @     |
| X X X X X X X X X |
|     X X     X X @ |
| X X X X X X X X X |
|   X X  @  X X     |
| X X X X X X X X X |
| X X @ X X  @  X X |
| X X X X X X X X X |
|                   |
---------------------

Added levels/lvl4.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|                   |
| X X X X X X X X X |
| B  #   #   #   #  |
| X X X X X X X X X |
|  #   #   #   #    |
| X X X X X X X X X |
|    #   #   #   #  |
| X X X X X X X X X |
|  #   #   #   #    |
| X X X X X X X X X |
|    #   # @ #   #  |
| X X X X X X X X X |
|  # @ #   # @ #    |
| X X X X X X X X X |
|    #   # @ #   #  |
| X X X X X X X X X |
|  # @ #   #   #  @ |
| X X X X X X X X X |
|                   |
---------------------

Added levels/lvl5.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|                   |
| X X X ##### X X X |
|       #####   X   |
| X X X ##### X X X |
| B X   #####  @    |
| X X X ##### X X X |
|       #####    @  |
| X X X ##### X X X |
|                   |
| X X X ##### X X X |
|   X   #####       |
| X X X ##### X X X |
|       #####   X @ |
| X X@X ##### X X X |
|       #####    @  |
| X X X ##### X X X |
|   X   #####   X   |
| X X X ##### X X X |
|    @              |
---------------------

Added levels/lvl6.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|  B X              |
| X XXX#X X XXXXX#X |
| # #   X   X     X |
| X X X X X X XXX X |
|   X     # X X@# XX|
|XX X XXX X XXX X X |
|       # X     X X |
| X X X X X X XXX X |
| X #               |
| XXXXX X X X XXXXX |
|   @   #     X     |
| X X#XXX XXX X X X |
| X          @#   # |
| X X XXX X#X X X X |
| X # X X X   X   X |
|XX XXX X X X X X X |
| X   @ X         X |
| X#XXXXX X XXX#XXX |
|  @          X  @  |
---------------------

Added levels/lvl7.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|B                  |
| XXXXXXXX XXXXXXXX |
| X               X |
| X XXXXXXXXXXXXX X |
| X X           X X |
| X X XXXX XXXX X X |
| X X X@  @  @X X X |
| X X X XX#XX X X X |
| X X X #X@X# X X X |
|   X   XX#XX   X   |
| X X X #X@X# X X X |
| X X X XX#XX X X X |
| X   X@  @  @X   X |
| X X XXXX XXXX X X |
| X X           X X |
| X XXXXXXXXXXXXX X |
| X               X |
| XXXXXXXX XXXXXXXX |
|                   |
---------------------

Added levels/lvl8.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|XXXXXXXXXXXXXXXXXXX|
|X        B        X|
|XXXX XXXX XXXX XXXX|
|X                 X|
|XXXX XXXX XXXX XXXX|
|X                 X|
|XXXX XXXX XXXX XXXX|
|X                 X|
|XXXX XXXX XXXX XXXX|
|X                 X|
|XXXX XXXX XXXX XXXX|
|X                 X|
|XXXX XXXX XXXX XXXX|
|X                 X|
|XXXX XXXX XXXX XXXX|
|X   @    @    @   X|
|XXXX XXXX XXXX XXXX|
|X   @    @    @   X|
|XXXXXXXXX XXXXXXXXX|
---------------------

Added levels/lvl9.txt.











































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
---------------------
|XXXXXXXXX XXXXXXXXX|
|XXXXXXXX   XXXXXXXX|
|XXXXXXX  X  XXXXXXX|
|XXXXXX   #@  XXXXXX|
|XXXXX  X # X  XXXXX|
|XXXX   # X #   XXXX|
|XXX  X # X # X  XXX|
|XX   X # # # X   XX|
|X  X # X # X # X  X|
|XB X # X@X X # X @X|
|X  X # X # X # X  X|
|XX   X # # # X   XX|
|XXX  X # X # X  XXX|
|XXXX   # X #   XXXX|
|XXXXX  X # X  XXXXX|
|XXXXXX   #@  XXXXXX|
|XXXXXXX  X  XXXXXXX|
|XXXXXXXX   XXXXXXXX|
|XXXXXXXXX XXXXXXXXX|
---------------------

Added levels/maps.txt.



















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
lvl1.txt
lvl2.txt
lvl3.txt
lvl4.txt
lvl5.txt
lvl6.txt
lvl7.txt
lvl8.txt
lvl9.txt
lvl10.txt
lvl11.txt
lvl12.txt
lvl13.txt
lvl14.txt
lvl15.txt
lvl16.txt
lvl17.txt
lvl18.txt
lvl19.txt
lvl20.txt
lvl21.txt
lvl22.txt
lvl23.txt
lvl24.txt
lvl25.txt

Added main.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
/*
==================================================
main.c
By: Donny Ward


Description:

Main file that starts first, runs everything else. Displays a menu and allows the user to pick an option.

Currently uses move.c to start the game. If move.c is edited significantly please make note of it.
==================================================
*/


#include <stdio.h>
#include <stdlib.h>
#include <curses.h>
#include <signal.h>
#include <pthread.h>
#include <float.h>
#include "map.h"

//int move();
void* th_print();
void* th_move();
void* th_ai();
void* th_end_in();
void main_menuup(int * o); //move up 1 in the menu
void main_menudown(int * o); //move down 1 in the menu
void main_framenew(); //draw menu with new game selected
void main_frameload(); //draw menu with load game selected
void main_frameexit(); //draw menu with frame exit selected
void main_frameLevel(int n); //display screen telling you level number
void main_framelose(); //displays a screen telling you that you died
int main_framewin();
void main_threadwin();
void main_framewin1();
void main_framewin2();
void main_printerror(char e[]); //print error messages

extern map * maps;
extern int lvlOver;
int gameresult;
int input_end;

enum optiontype
{
	newgame = 0,
	loadgame,
	exittowindows, //exit is used already
};

int main (int argc, char * argv[])
{
	WINDOW * mainwin;
	
	mainwin = initscr();
	raw();
	keypad(stdscr, TRUE);
	noecho();
		
	clear();
	int finish = 0;
	char c;
	int input;
	int numLvl = 1;
	int progress;


	int option = newgame;

	init_new_game();

	while (!finish)
	{	
		if (option == newgame)
			main_framenew();
		else if (option == loadgame)
			main_frameload();
		else if (option == exittowindows)
			main_frameexit();

		refresh();

		input = getch();

		while (input != 10) //return key or enter key
		{
			if (input == KEY_UP)
				main_menuup(&option);
			else if (input == KEY_DOWN)
				main_menudown(&option);

			input = getch();
		}

		switch (option)
		{
			case newgame: //then let the games begin
				input_end = 0;				
				lvlOver = 0;
				numLvl = 1;				

				main_frameLevel(numLvl);
				start_new();
				pthread_t print, move, ai;

				pthread_create(&print, NULL, th_print, NULL);
				pthread_create(&move, NULL, th_move, NULL);
				pthread_create(&ai, NULL, th_ai, NULL);
				
				pthread_join(print, NULL);
				pthread_join(move, NULL);
				pthread_join(ai, NULL);

				pthread_detach(print);
				pthread_detach(move);
				pthread_detach(ai);

				e_clear(); //clear enemys
				mp_s_clear(); //clear spaces 'array'

				if (gameresult == 0) //player died
				{//show 'you died' screen before going back to main menu
					free(maps->buffer); //clear buffer of chars from map text files
					main_framelose();
				}
				else if (gameresult == 1) //player won
				{//go to next level
					//display brief victory animated screen (will require thread)
					//integrate julio's level progression code here
					do
					{
						if(gameresult == 1)
						{
							lvlOver = 0;
							progress = next_lvl();
							
							if(progress == 1){
								numLvl++;
								main_frameLevel(numLvl);
								pthread_create(&print, NULL, th_print, NULL);
								pthread_create(&move, NULL, th_move, NULL);
								pthread_create(&ai, NULL, th_ai, NULL);

								pthread_join(print, NULL);
								pthread_join(move, NULL);
								pthread_join(ai, NULL);
								
								pthread_detach(print);
								pthread_detach(move);
								pthread_detach(ai);
			
								e_clear(); //clear enemys
								mp_s_clear(); //clear spaces 'array'							
								
								if(gameresult == 0){
									free(maps->buffer); //clear buffer of chars from map text files
									main_framelose();
									break;
								}
							}
							else{
								free(maps->buffer); //clear buffer of chars from map text files
								clear();
								lvlOver = 1;
								gameresult = 2;
								break;
							}
						}
					}while(gameresult != 0 || gameresult != 2);
	
				}
				if (gameresult == 2) //player wins completely
				{
					free(maps->buffer); //clear buffer of chars from map text files
					pthread_t endin;
					pthread_create(&endin, NULL, th_end_in, NULL);
					main_threadwin();
					pthread_detach(endin);
				}

				noecho();
				break;
			case loadgame:
				main_printerror("Load game doesn't work yet!");
				clear();
				break;
			case exittowindows:
				finish = 1;
				break;
			default:
				break;
		}
	}
	
	printw("[Bomberman] : Exiting game...\n");
	refresh();
	bm_clear();
	mp_clear();
	usleep(500000); //0.5 sec
	endwin(); //exits window
	return 0;
}

void* th_print()
{
	while(!lvlOver){
		usleep(20000);
		mp_print();
	}
	pthread_exit(NULL);
}

void* th_move()
{
	while(!lvlOver){
		usleep(40000);
		gameresult = m_move();
	}
	pthread_exit(NULL);
}

void* th_ai()
{
	int time = 1000000; //1 secs
	int t;
	while(!lvlOver){
		t = time * 0.98;
		if ( t > 110000 ) //.110 sec
			time = t;
		usleep(time);
	
		e_think();
	}
	pthread_exit(NULL);
}

void* th_end_in()
{
	while(!input_end){
		usleep(20000);
		main_framewin();
	}
	pthread_exit(NULL);
}

void main_menuup(int * o)
{
	clear();

	if (*o == newgame) //then jump to end of list
	{
		main_frameexit();
		*o = exittowindows;
	}
	else
	{
		if (*o == loadgame)
		{
			main_framenew();
			*o = newgame;
		}
		else if (*o == exittowindows)
		{
			main_frameload();
			*o = loadgame;
		}
	}

	refresh();
}

void main_menudown(int * o)
{
	clear();

	if (*o == exittowindows) //then jump to top of list
	{
		main_framenew();
		*o = newgame;
	}
	else
	{
		if (*o == newgame)
		{
			main_frameload();
			*o = loadgame;
		}
		else if (*o == loadgame)
		{
			main_frameexit();
			*o = exittowindows;
		}
	}

	refresh();
}

//have to use printw instead of printf
void main_framenew()
{
	//50 spaces across
	printw(
	"==================================================\n"
	"\n"
	"\n"
	"\n"
	"                    BOMBERMAN!\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"                 *** NEW GAME ***\n"
	"\n"
	"                     LOAD GAME\n"
	"\n"
	"                  EXIT TO WINDOWS\n"
	"\n"
	"--Up and down arrows to navigate--\n"
	"--Enter to make selection--\n"
	"==================================================\n"
	);
}

void main_frameload()
{
	//50 spaces across
	printw(
	"==================================================\n"
	"\n"
	"\n"
	"\n"
	"                    BOMBERMAN!\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"                     NEW GAME    \n"
	"\n"
	"                 *** LOAD GAME ***\n"
	"\n"
	"                  EXIT TO WINDOWS\n"
	"\n"
	"--Up and down arrows to navigate--\n"
	"--Enter to make selection--\n"
	"==================================================\n"
	);
}

void main_frameexit()
{
	//50 spaces across
	printw(
	"==================================================\n"
	"\n"
	"\n"
	"\n"
	"                    BOMBERMAN!\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"                     NEW GAME\n"
	"\n"
	"                     LOAD GAME\n"
	"\n"
	"              *** EXIT TO WINDOWS ***\n"
	"\n"
	"--Up and down arrows to navigate--\n"
	"--Enter to make selection--\n"
	"==================================================\n"
	);
}

void main_frameLevel(int n)
{
	clear();
	printw(
	"==================================================\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"		     Level %d\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"==================================================\n"
	,n);
	refresh();
	sleep(1);
	clear();
}

void main_framelose()
{
	clear();
	printw(
	"==================================================\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"                    YOU LOSE...\n"
	"\n"
	"\n"
	"\n"
	"                      O    O\n"
	"                        **\n"
	"                      *    *\n"
	"                     *      *\n"
	"\n"
	"\n"
	"\n"
	"==================================================\n"
	);
	refresh();
	sleep(1);
	clear();
}

int main_framewin()
{
	int input;
	input = getch();
	if(input == 10)
		input_end = 1;
}

void main_threadwin()
{
	while (!input_end)
	{
		main_framewin1();
		usleep(500000);
		clear();
		main_framewin2();
		usleep(500000);
		clear();
	}
}

void main_framewin1()
{
	printw(
	"==================================================\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"                      YOU WIN!\n"
	"\n"
	"\n"
	"                         o\n"
	"                        /|\\ \n"
	"                        / \\ \n"
	"\n"
	"\n"
	"\n"
	"\n"
	"--Press Enter to continue--\n"
	"==================================================\n"
	);
	refresh();
}

void main_framewin2()
{
	printw(
	"==================================================\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"                      YOU WIN!\n"
	"\n"
	"\n"
	"                       \\ o /\n"
	"                         |\n"
	"                        / \\  \n"
	"\n"
	"\n"
	"\n"
	"\n"
	"--Press Enter to continue--\n"
	"==================================================\n"
	);
	refresh();
}


void main_printerror(char e[])
{
	printw("ERROR: %s\n", e);
/*
	printw(
	"==================================================\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	);

	printw("ERROR: %s\n", e);

	printw(
	"\n"
	"              Press Enter to continue\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"\n"
	"==================================================\n"
	);

	getch();
*/
	refresh();
}

Added map.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
/*************************************************
map.c

By: Donny Ward
Edited By: Julio Pescador

TO EVERYONE:

I made functions mp_checkspace and mp_checkrelative. use these
functions to check if a space has something.

//check if a specific space has property
int mp_checkspace(map * m, int row, int col, int property);

//check if a space relative to the one specified has property. multiplier to check subsequent spaces
int mp_checkrelative(map * m, int row, int col, int dir, int multiplier, int property); 

m = the map pointer to the  map
row, col = the row and column that the space belongs to
property = integer value that determines what the function will check for. use these enum values for property:
	
	has_bomb
	has_bman
	has_soft
	has_item
	has_hard

	the function will check the space to see if it has whatever you are looking for and return 1
	if it is there, and 0 if it is not there.


mp_checkrelative is used to let you easily check a status of a space relative to the one that you know about (ex: origin of a bomb blast)
multiplier is used to check spaces x times beyond the first one in that direction. valid dir values are:

	dir_left
	dir_right
	dir_up
	dir_down

example: if you have an explosion starting at row 2 column 2, and you want to see if theres anything in the way at the space right below this one:
	if ( mp_checkrelative(m, 2, 2, dir_down, 1, has_soft) == 1 )
	if ( mp_checkrelative(m, 2, 2, dir_down, 1, has_bomb) == 1 )

	so if there is a soft block in that location you blow it up. if theres a bomb in that location you blow it up prematurely and set off its own explosions

	if there was nothing there and you want the explosion to continue to the block beyond it, you would check that block by changing the multiplier to 2.

	if ( mp_checkrelative(m, 2, 2, dir_down, 2, has_soft) == 1 )

	etc.


these functions are invaluable for collision detection for players, bombs, actors, and everything in between.
examples of practicale use are:

-making a bomb explosion recursively check adjacent sectors in a straight line to see how far the bomb blast should go

thats all i could think of for now.


whenever a space on the map changes it must be updated. maps->map[row][col] is the space structure at (col, row). so a bomb destroys
something (be it a player or item or whatever) on a space, that space must be updated to reflect this. the current values held are:

	int is_bomb; //is there a bomb on this space?
	int is_bman; //is there a bomberman on this space?
	int is_soft; //is there a soft block on this space?
	int is_item; //is there an item on this space?
	int is_hard; //is there a hard block on this space?	

set to 1 if true and 0 if false

-Donny

note: i didnt finish checkrelative yet, only checkspace works

*************************************************/


#include "map.h"
#include "p_bman.h"
#include "enemy.h"

#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <time.h>

map * maps; //global map variable
space * spaces; //refer to a specific space member with spaces[i]. not spaces[i]-> because [i] gets the struct at that point, not a pointer to it

extern enemy * enemys[MAX_ENEMIES];
extern bomberman* b;
extern int num_enemys_total;
extern int num_enemys_alive;
extern lvlOver;

/*********************************
allocates space for space structure
**********************************/
void mp_s_alloc(space ** s, int size)
{
	int i;

	space * temp = (space *)malloc(sizeof(space) * size);
	*s = temp;

	for (i = 0; i < size; i++) //initialize every space to a clean slate
	{
		(*s)[i].icon = '~'; //the character that will be displayed on the map for this space
		(*s)[i].is_bomb = 0; //is there a bomb on this space?
		(*s)[i].is_bman = 0; //is there a bomberman on this space?
		(*s)[i].is_soft = 0; //is there a soft block on this space?
		(*s)[i].is_item = 0; //is there an item on this space?
		(*s)[i].is_hard = 0; //is there a hard block on this space?
		(*s)[i].is_enemy = 0; //is there an enemy on this space?
		(*s)[i].is_dead = 0;

		(*s)[i].f = 0; //f score. f = g + h
		(*s)[i].g = 0; //the movement cost to move from starting point to this space
		(*s)[i].h = 0; //'heuristic'. estimated movement cost to move from here to destination
		//(*s)[i].open; //is this space on the open list? 1 or 0
		//(*s)[i].closed; //is this space on the closed list? 1 or 0
		(*s)[i].parent = NULL; //points to the parent of this space
	}
}

/*********************************
frees memory from space structure
**********************************/
void mp_s_clear()
{
	free(spaces);
}

/*********************************
allocates space for map structure
**********************************/
void mp_alloc(map ** m)
{
	map *temp = ((map *)malloc(sizeof(map)));
	*m = temp;
	(*m)->iterate = 0;
	(*m)->sizex = 0;
	(*m)->sizey = 0;
}

/*********************************
frees memory from map structure
**********************************/
void mp_clear()
{
	free(maps);
}

/****************************************************************************
  This function reads in a file: maps.txt and stores the txts into an array
  called arrayMaps
*****************************************************************************/
void mp_readMapsInfo()
{
	memset(&(maps->arrayMaps[0]), 0, sizeof(maps->arrayMaps));	
	FILE * pFile;
	int c;
	pFile = fopen("levels/maps.txt", "r");
	if(pFile == NULL)
		printw("Error opening file");
	else{
		c = getc(pFile);
		while(c != EOF)		
		{
			maps->arrayMaps[maps->iterate] = c;
			maps->iterate++;

			c = getc(pFile);
		}
		fclose (pFile);
	}

	maps->iterate = 0;
}

/*********************************************************************************
  this function, mp_readMap, uses the arrayMaps array from the previous function and 
  will call each txt in that array one at a time. 
*********************************************************************************/
int mp_readMap()
{
	int spacesize;

	int count = 0;
	if(maps->arrayMaps[maps->iterate] != 0){
	memset(&(maps->fMapLvl[0]), 0, sizeof(maps->fMapLvl));
	while(maps->arrayMaps[maps->iterate] != '\n')
	{
		maps->fMapLvl[count] = maps->arrayMaps[maps->iterate];
		maps->iterate++;
		count++;
	}
	//printw("%s", maps->fMapLvl); //debug
	

	char* temp = maps->fMapLvl;

	char str[20];// = "levels/";
	memset(&(str[0]), 0, sizeof(str));
	strcpy(str, "levels/");
	strcat(str, temp);	
	
	int row = 0, col = 0;
	int doOnce = 1;
	//printw("%s", temp); //debug
	FILE * pFile;
	char c;
	pFile = fopen(str, "r");
	if (pFile==NULL) 
		printw ("Error opening file");
	else
	{
		c = getc(pFile);
		while(c != EOF)
		{
			col++;
			if(c == '\n')
			{
				maps->sizey = col-1;
				col= 0;
				row++;	
			}
			c = getc(pFile);
		}
		maps->sizex = row;
		//printw("row: %d", row); //debug
		fclose(pFile);
		
	}

	count = 0;

	//following 2 lines from donny. this fixes the problem of corrupt map displaying. more info at the end of this function.
	spacesize = maps->sizex * maps->sizey;
	maps->buffer = (char *)malloc(sizeof(char) * spacesize); 

	memset(&(str[0]), 0, sizeof(str));
	strcpy(str, "levels/");
	strcat(str, temp);
	pFile = fopen(str, "r");
	if (pFile==NULL) 
		printw ("Error opening file");
	else
	{
		c = getc(pFile);
		while(c != EOF)
		{
			if(c != '\n'){
				maps->buffer[count] = c;
				count++;
			}
			c = getc(pFile);
			
		}
		fclose(pFile);
		
	}
/*
Dangling pointers arise when an object is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory. As the system may reallocate the previously freed memory to another process, if the original program then dereferences the (now) dangling pointer, unpredictable behavior may result, as the memory may now contain completely different data. This is especially the case if the program writes data to memory pointed by a dangling pointer, a silent corruption of unrelated data may result, leading to subtle bugs that can be extremely difficult to find
*/
	maps->mapLvl = maps->buffer; //when this function goes out of scope, (julio's) buffer was released from memory. maps->mapLvl was dangling pointer
	return 1;
}
/*
This bug has been present for a long time now, but it only showed itself when the space structure was changed to allocate memory
dynamically during runtime. The reason for this is that, by chance, when sMap was just a space array, the program ran in it's entirety without
overwriting the contents of buffer. mapLvl pointed to buffer, and the program never touched this location of memory again so it remained uncorrupted.
When sMap was changed to a pointer with dynamic memory allocation, the program at runtime used the location of memory that mapLvl pointed to to
allocate space for sMap. This resulted in the buffer data at that location becoming corrupted, and thus corrupting mapLvl (which was pointing to
memory that was released back to the system). This is now fixed by manually allocating memory for buffer. Now later on we just have to make sure to
manually free() this memory.
*/
else
	return 0;

}

/****************************************************************************************
  This function, mp_create, takes the char* mapLvl and places the characters in the space
  structure: s[ROW*COL]. With the space structure declared this way, each space
  in the map has its own space struct data. Space structure is declared as
  s[ROW*COL] rather than s[ROW][COL] because i couldn't get the latter to work
  so i ended up using the 1d approach instead. so a position at s[0][0] is 
  equivalent to s[0] and s[0][1] is equivalent to s[0+COL]. Think back to the
  magic squares lab if you coded the array as a 1d array rather than 
  multi-dimensional.
*****************************************************************************************/
void mp_create()
{	
	int i;
	int spacesize;

	char * t;
	spacesize = maps->sizex * maps->sizey;
	for (i = 0; i < spacesize; i++)
	{
		t = maps->mapLvl;
		//t[i] is the char for a specific spot on the map

		if ( t[i] != none && t[i] != BARRICADE && t[i] != soft && t[i] != HWALL && t[i] != VWALL && t[i] != BMAN && t[i] != mob && t[i] != BOMB && t[i] != XPLODE )
		{
			clear();
			printw("maps->sizex = %d, maps->sizey = %d\n", maps->sizex, maps->sizey);
			//printw("maps->sizex = %d, maps->sizey = %d\n", maps->sizex, maps->sizey);
			refresh();
			spaces[i].icon = '$';
		}
		else
		{
			spaces[i].icon = t[i];
		}
	}

	//This for loop checks each space if there is hard block,
	//soft block, player, etc. present in space

	int e_index = 0;
	for(i = 0; i < maps->sizex*maps->sizey; i++)
	{
		spaces[i].pos = i; //the space must know where it is

		//no longer need to set values to 0. all default to 0 when alloc'd.
		if(spaces[i].icon == HWALL)
		{
			spaces[i].is_hard = 1;
		}	
		else if(spaces[i].icon == VWALL)
		{
			spaces[i].is_hard = 1;
		}
		else if(spaces[i].icon == BARRICADE)
		{
			spaces[i].is_hard = 1;
		}
		else if(spaces[i].icon == soft)
		{
			spaces[i].is_soft = 1;
		}
		else if(spaces[i].icon == BMAN)
		{
			spaces[i].is_bman = 1;
		}
		else if(spaces[i].icon == none)
		{
			//nothing
		}
		else if (spaces[i].icon == mob) //a enemy starts in this spot
		{
			if (e_index >= MAX_ENEMIES) //cant hold anymore enemies
			{
				spaces[i].icon = none; //just pretend nothing was here
			}
			else
			{
				spaces[i].is_enemy = 1;

				e_alloc(&enemys[e_index]); //allocate space for this actor
				e_setpos(enemys[e_index], i); //write in the location to the actor's memory
				e_index++;
			}
		}			

	}//end of for loop
	num_enemys_total = e_index; //keep track of total # of enemies in round
	num_enemys_alive = num_enemys_total;
}


//prints out map to screen
void mp_print()
{	
	clear();
	int count = 0;
	int count1 = 1;
	int count2 = 0;
	while(count != maps->sizex * maps->sizey)
	{	
		printw("%c", spaces[count].icon);
		if(count1 == maps->sizey){
			printw("\n");
			count1 = 0;
		}
		if(spaces[count].is_enemy == 1)
			count2++;
		count1++;
		count++;
	}
	num_enemys_alive = count2;
	printw(
	"Press arrow keys to move\n"
	"Press spacebar key to drop bomb\n"
	"Enemys Alive: %d\n", num_enemys_alive
	);
	refresh();	
}

/******************************************************************
mp_startPosition finds starting position using the space structure 
based if is_bman is true in any of the indexes and places index 
into bomberman player position, b->pp
******************************************************************/
void mp_startPosition()
{
	int i;
	for(i = 0; i < maps->sizex*maps->sizey; i++)
	{
		if(spaces[i].is_bman == 1)
			b->pp = i;
	}
	//printw("%d", b->pp); //debug
}

//this function gets the symbol from the s[] structure if
//BMAN character is present in any of the indexes
char mp_getSymbol()
{
	int i;
	char symbol;
	for(i = 0; i < maps->sizex*maps->sizey; i++)
	{
		if(spaces[i].icon == BMAN)
		{
			symbol = BMAN;
		}
	}
	return symbol;
}


/**********************************************************************
In this function mp_playerInput b->ppr and b->ppc have been changed 
to just b->pp since the spaces structure is 1d and not a multi array 
otherwise if were using s[][] then we would be using b->ppr and b->ppc
**********************************************************************/
int mp_playerInput()
{
	int i;

	if(b->alive != 0){
		maps->input = getch();

		if(maps->input == KEY_RIGHT)
		{
			b->pp++;
		
			//undo movement if hard block, X, or soft block, #, is present
			if(mp_checkspace(b->pp, has_hard) == 1)
				b->pp--;
			else if(mp_checkspace(b->pp, has_soft) == 1)
				b->pp--;
			//kill bomberman if he walks into an enemy, @, or explosion, +, tile
			else if (mp_checkspace (b->pp, has_enemy) == 1) //enemy here, die die die
				bm_kill(b);
			else if (mp_checkspace (b->pp, has_xplode) == 1) //bomb explosion, dead
				bm_kill(b);
			//otherwise move symbol to next space, clear old space, and also update is_bman values
			else if((b->alive != 0) && (num_enemys_alive != 0)){
				spaces[b->pp].icon = b->symbol;
				spaces[b->pp].is_bman = 1;
				if(spaces[b->pp-1].is_bomb == 1)
					spaces[b->pp-1].icon = BOMB;
				else
					spaces[b->pp-1].icon = none;
				spaces[b->pp-1].is_bman = 0; 
				spaces[b->pp-1].is_soft = 0;
			}
		}
		else if(maps->input == KEY_LEFT)
		{
			b->pp--;
			
			//undo movement if hard block, X, or soft block, #, is present
			if(mp_checkspace(b->pp, has_hard) == 1)
				b->pp++;
			else if(mp_checkspace(b->pp, has_soft) == 1)
				b->pp++;
			//kill bomberman if he walks into an enemy, @, or explosion, +, tile
			else if (mp_checkspace (b->pp, has_enemy) == 1) //enemy here, die die die
				bm_kill(b);
			else if (mp_checkspace (b->pp, has_xplode) == 1) //bomb explosion, dead
				bm_kill(b);
			//otherwise move symbol to next space, clear old space, and also update is_bman values
			else if((b->alive != 0) && (num_enemys_alive != 0)){
				spaces[b->pp].icon = b->symbol;
				spaces[b->pp].is_bman = 1;
				if(spaces[b->pp+1].is_bomb == 1)
					spaces[b->pp+1].icon = BOMB;
				else
					spaces[b->pp+1].icon = none;
				spaces[b->pp+1].is_bman = 0; 
				spaces[b->pp+1].is_soft = 0;
			}
		}
		else if(maps->input == KEY_DOWN)
		{
		
			b->pp += maps->sizey;
			
			//undo movement if hard block, X, or soft block, #, is present
			if(mp_checkspace(b->pp, has_hard) == 1)
				b->pp -= maps->sizey;
			else if(mp_checkspace(b->pp, has_soft) == 1)
				b->pp -= maps->sizey;
			//kill bomberman if he walks into an enemy, @, or explosion, +, tile
			else if (mp_checkspace (b->pp, has_enemy) == 1) //enemy here, die die die
				bm_kill(b);
			else if (mp_checkspace (b->pp, has_xplode) == 1) //bomb explosion, dead
				bm_kill(b);
			//otherwise move symbol to next space, clear old space, and also update is_bman values
			else if((b->alive != 0) && (num_enemys_alive != 0)){
				spaces[b->pp].icon = b->symbol;
				spaces[b->pp].is_bman = 1;
				if(spaces[b->pp-maps->sizey].is_bomb == 1)
					spaces[b->pp-maps->sizey].icon = BOMB;
				else				
					spaces[b->pp-maps->sizey].icon = none;
				spaces[b->pp-maps->sizey].is_bman = 0;
				spaces[b->pp-maps->sizey].is_soft = 0; 
			}
		}
		else if(maps->input == KEY_UP)
		{
			b->pp -= maps->sizey;
			
			//undo movement if hard block, X, or soft block, #, is present
			if(mp_checkspace(b->pp, has_hard) == 1)
				b->pp += maps->sizey;
			else if(mp_checkspace(b->pp, has_soft) == 1)
				b->pp += maps->sizey;
			//kill bomberman if he walks into an enemy, @, or explosion, +, tile
			else if (mp_checkspace (b->pp, has_enemy) == 1) //enemy here, die die die
				bm_kill(b);
			else if (mp_checkspace (b->pp, has_xplode) == 1) //bomb explosion, dead
				bm_kill(b);
			//otherwise move symbol to next space, clear old space, and also update is_bman values
			else if((b->alive != 0) && (num_enemys_alive != 0)){
				spaces[b->pp].icon = b->symbol;
				spaces[b->pp].is_bman = 1;
				if(spaces[b->pp+maps->sizey].is_bomb == 1)
					spaces[b->pp+maps->sizey].icon = BOMB;
				else
					spaces[b->pp+maps->sizey].icon = none;
				spaces[b->pp+maps->sizey].is_bman = 0;
				spaces[b->pp+maps->sizey].is_soft = 0;
			}
		}
		else if (maps->input == 'k') //kill the player. 107 = ascii for 'k'
		{
			bm_kill(b);
		}
		else if (maps->input == 'w') //i win button. kills all enemies
		{
			e_clear();
		}
		else if(maps->input == 32) //ascii for spacekey 
	 	{ 
			if(b->b_active == 0)
			{
				if((b->alive != 0) && (num_enemys_alive != 0)){
				pthread_t bombs;
				pthread_create(&bombs, NULL, mp_bomb, NULL);
				pthread_detach(bombs); //reclaim storage once thread is done
				}
			}
		} 

		return 1; //success
	}
	else
		return 0; //failure. player is dead
}

void* mp_bomb()//void* ptr) //use to be bomberman b
{ 
	spaces[b->pp].icon = BOMB;//neway places icon, changes bomb placed variable etc 
	spaces[b->pp].is_bomb = 1;//julio whhat fun draws bomb icon?  
	
	b->b_active = 1; 
	b->bpp=b->pp;
	
	usleep(1300000); //1.3 secs
	mp_explode(b);
	usleep(500000); //0.5 sec
	mp_cleanXplode(b);
	
	b-> b_active =0;
	pthread_exit(NULL);
	
	// make sleep
	// then call xplode
	// then exit
} 

void mp_hurry()
{
	//do nothing
}

/*
PROPERTIES:
	has_bomb,
	has_bman,
	has_soft,
	has_item,
	has_hard,
*/
int mp_checkspace(int playerPosition, int property) //check if a specific space has property
{
	switch (property)
	{
		case has_bomb:
			return (spaces[playerPosition].is_bomb); //map is the name of the array of space structs
			break;
		case has_bman:
			return (spaces[playerPosition].is_bman);
			break;
		case has_soft:
			return (spaces[playerPosition].is_soft);
			break;
		case has_item:
			return (spaces[playerPosition].is_item);
			break;
		case has_hard:
			return (spaces[playerPosition].is_hard);
			break;
		case has_enemy:
			return (spaces[playerPosition].is_enemy);
			break;
		case has_xplode:
			return (spaces[playerPosition].is_dead);
			break;
		default:
			return 0;
	}
}

int mp_walkable(int pos)
{
	int bomb = mp_checkspace(pos, has_bomb);
	//int enemy = mp_checkspace(pos, has_enemy);
	int hard = mp_checkspace(pos, has_hard);
	int soft = mp_checkspace(pos, has_soft);

	if ( !bomb && !hard && !soft ) //no hard/soft blocks, and no bombs here
		return 1;
	else
		return 0;
}

int mp_getrelative(int pos, int dir)
{
	if (dir == dir_up)
	{
		pos -= maps->sizey;
	}
	else if (dir == dir_down)
	{
		pos += maps->sizey;
	}
	else if (dir == dir_left)
	{
		pos -= 1;
	}
	else if (dir == dir_right)
	{
		pos += 1;
	}

	return pos;
}

void mp_getcoords(int pos, int * x, int * y)
{
//sizex and sizey are backwards
//do the math on paper, this checks out
//top left space is pos 0, left to right, top to bottom
//top left space is (0, 0), space to the right is (1, 0), space below first is (0, 1).
	*x = pos % maps->sizey;
	*y = pos / maps->sizey;
}

void mp_explode()
{
	int i;
	spaces[b->bpp].icon = XPLODE;
	spaces[b->bpp].is_dead = 1;
	if(spaces[b->bpp].is_bman == 1)
		bm_kill(b);

	/*for(i = 0; i < num_enemys_total; i++){
		if(enemys[i]->pp == b->bpp-1){
			e_kill(enemys[i]);
			//spaces[b->bpp-1].is_enemy = 0;
			spaces[(b->bpp-1)].icon = XPLODE;
		}
				//if(spaces[b->bpp-1].is_enemy == 1)
	}*/	

	if(!(spaces[b->bpp-1].icon==BARRICADE||spaces[b->bpp-1].icon==HWALL||spaces[b->bpp-1].icon==VWALL))//checks left
	{
			spaces[(b->bpp-1)].icon = XPLODE;
			spaces[b->bpp-1].is_dead = 1;
			if(spaces[b->bpp-1].is_bman == 1)
				bm_kill(b);
			for(i = 0; i < num_enemys_total; i++){
				if(enemys[i]->pp == b->bpp-1){
					e_kill(enemys[i]);
					spaces[(b->bpp-1)].icon = XPLODE;
				}
				//if(spaces[b->bpp-1].is_enemy == 1)
			}
	}

	if(!(spaces[b->bpp+1].icon==BARRICADE||spaces[b->bpp+1].icon==HWALL||spaces[b->bpp+1].icon==VWALL))//checks right
	{
			spaces[(b->bpp+1)].icon= XPLODE;
			spaces[b->bpp+1].is_dead = 1;
			if(spaces[b->bpp+1].is_bman == 1)
				bm_kill(b);
			for(i = 0; i < num_enemys_total; i++){
				if(enemys[i]->pp == b->bpp+1){
					e_kill(enemys[i]);
					//spaces[b->bpp+1].is_enemy = 0;
					spaces[(b->bpp+1)].icon= XPLODE;
				}
				//if(spaces[b->bpp+1].is_enemy == 1)
			}
	}

	int up= b->bpp+maps->sizey;
	int down= b->bpp-maps->sizey;

	if(!(spaces[up].icon==BARRICADE||spaces[up].icon==HWALL||spaces[up].icon==VWALL))
	{
			spaces[(up)].icon= XPLODE;
			spaces[up].is_dead = 1;
			if(spaces[up].is_bman == 1)
				bm_kill(b);
			for(i = 0; i < num_enemys_total; i++){
				if(enemys[i]->pp == up){
					e_kill(enemys[i]);
					//spaces[up].is_enemy = 0;
					spaces[(up)].icon= XPLODE;
				}
				//if(spaces[up].is_enemy == 1)
			}
	}

	if(!(spaces[down].icon==BARRICADE||spaces[down].icon==HWALL||spaces[down].icon==VWALL))
	{
			spaces[down].icon= XPLODE;
			spaces[down].is_dead = 1;
			if(spaces[down].is_bman == 1)
				bm_kill(b);

			for(i = 0; i < num_enemys_total; i++){
				if(enemys[i]->pp == down){
					e_kill(enemys[i]);
					//spaces[down].is_enemy = 0;
					spaces[down].icon= XPLODE;
				}
			}
	}	
	//makes checks using b->bpp which is a placehodler for bombs location
		

}

void mp_cleanXplode()
{
	spaces[b->bpp].icon = none;
	spaces[b->bpp].is_bomb = 0;
	spaces[b->bpp].is_dead = 0;
	
	if(!(spaces[b->bpp-1].icon==BARRICADE||spaces[b->bpp-1].icon==HWALL||spaces[b->bpp-1].icon==VWALL))//checks left
	{
			if(spaces[b->bpp-1].is_soft == 1)
				spaces[b->bpp-1].is_soft = 0;
			spaces[(b->bpp-1)].icon = none;
			spaces[b->bpp-1].is_dead = 0;
	}

	if(!(spaces[b->bpp+1].icon==BARRICADE||spaces[b->bpp+1].icon==HWALL||spaces[b->bpp+1].icon==VWALL))//checks right
	{
			if(spaces[b->bpp+1].is_soft == 1)
				spaces[b->bpp+1].is_soft = 0;
			spaces[(b->bpp+1)].icon = none;
			spaces[b->bpp+1].is_dead = 0;
	}
	
	int up= b->bpp+maps->sizey;
	int down= b->bpp-maps->sizey;

	if(!(spaces[up].icon==BARRICADE||spaces[up].icon==HWALL||spaces[up].icon==VWALL))
	{
			if(spaces[up].is_soft == 1)
				spaces[up].is_soft = 0;
			spaces[(up)].icon= none;
			spaces[up].is_dead = 0;
	}

	if(!(spaces[down].icon==BARRICADE||spaces[down].icon==HWALL||spaces[down].icon==VWALL))
	{
			if(spaces[down].is_soft == 1)
				spaces[down].is_soft = 0;
			spaces[down].icon= none;
			spaces[down].is_dead = 0;
	}	
	//makes checks using b->bpp which is a placehodler for bombs location
}
//#endif

Added map.h.



































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#ifndef __MAP_H__
#define __MAP_H__

#include <stdlib.h>
#define MAXSIZE 265
#define MAX 12

//struct enemy; //forward declaration
//struct bomberman;

enum blocktype
{
	none = ' ',
	BARRICADE = 'X',
	soft = '#',
	HWALL = '-',
	VWALL = '|',
	BMAN = 'B',
	mob = '@',
	BOMB = 'O',
	XPLODE = '+',
};

enum spaceproperty
{
	has_bomb,
	has_bman,
	has_soft,
	has_item,
	has_hard,
	has_enemy,
	has_xplode,
};

enum directions
{
	dir_left = 0,
	dir_right = 1,
	dir_up = 2,
	dir_down = 3,

	//for pathfinding
	dir_northwest,
	dir_northeast,
	dir_southwest,
	dir_southeast,
};

/*
each space was previously represented by a character. the character of a space determined the properties
of that space (hard block, soft block, bomberman, etc). a space can have more then one property though. it can
have a bomberman as well as a bomb on it. it can have a soft block as well as an item hidden inside (forward thinking).
so now each space is represented by a structure.
*/
typedef struct space
{
	//in the future: store an array of pointers to objects that are on this space. 
	//so if you want to kill everyone on this space, it has a list of objects to kill available instead of having to
	//loop through every object that exists and compare its coords to see if it sits in this space
	char icon; //the character that will be displayed on the map for this space
	int is_bomb; //is there a bomb on this space?
	int is_bman; //is there a bomberman on this space?
	int is_soft; //is there a soft block on this space?
	int is_item; //is there an item on this space?
	int is_hard; //is there a hard block on this space?
	int is_enemy; //is there an enemy on this space?
	int is_dead; //enemy or bomberman dies!	

	//the following is for pathfinding purposes
	int pos; //1 dimensional array type position
	int f; //f score. f = g + h
	int g; //the movement cost to move from starting point to this space
	int h; //'heuristic'. estimated movement cost to move from here to destination
	int open; //is this space on the open list? 1 or 0
	int closed; //is this space on the closed list? 1 or 0
	struct space * parent; //points to the parent of this space
} space;
	

typedef struct map {
//note to self sizex and sizey are backwards. sizex is recording the size of the columns (number of rows as opposed to the length of each row)
//and sizey is recording the size of the rows
	int sizex; //row size of map which will be read from file
	int sizey; //column size of map which will be read from file
	char arrayMaps[MAXSIZE]; //load array of files from map.txt into here
	char fMapLvl[MAX]; //load from file map
	int iterate; //used to keep track of the map array loaded from maps.txt
        int input; //user input based on what is entered. ex: arrow keys, space bar, backspace, etc.
	char* mapLvl; //reads data from file txt
	char* buffer;
} map;

void mp_s_alloc(space ** s, int size); //allocate memory for space structure
void mp_alloc(map ** m); //allocate memory for map structure
void mp_s_clear(); //free memory from space structure
void mp_clear(); //free memory from map structure
void mp_readMapsInfo(); //function reads in array of lvl txts from maps.txt file in levels folder
int mp_readMap(); //function reads in information of lvlx.txt (x = 1, 2, 3, 4,...,n)
void mp_create(); //places information of the lvlx.txt into the space structure
void mp_print(); //prints map to screen
void mp_startPosition(); //gets starting position of bomberman from the space structure
char mp_getSymbol(); //gets symbol of bomberman
int mp_playerInput(); //Player input(bomberman)
void* mp_bomb();//void* ptr);// added this to do bomb calculations. needs to edit map explosion, edit bomb bool(checks if u can set), also need a bomberman bomb counter for keyspace; will call check relative . use to take bomberman struct
//void mp_hurry(); //alters the map by adding blocks to the outer edges (smaller playing field) //did not get to add this function into game :(
int mp_checkspace(int playerPosition, int property); //check if a specific space has property

int mp_walkable(int pos); //1 if position is walkable, 0 if not
int mp_getrelative(int pos, int dir); //return the pos that is 'dir' from the given position
void mp_getcoords(int pos, int * x, int * y); //convert 1-dimensional position into x and y coords
void mp_explode();//makes checks
void mp_cleanXplode();
#endif

Added p_bman.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
//unnecessary, only use for .h files
//#ifndef BOMBERMAN_C
//#define BOMBERMAN_C
#include<stdlib.h>
#include<string.h>

#include "p_bman.h"
#include <stdlib.h>

bomberman* b;

void bm_alloc(bomberman **b)
{
	//allocate space for structure bomberman
	bomberman *temp = ((bomberman *)malloc(sizeof(bomberman)));
	*b = temp;
	//set default values
	(*b)->alive = 1;
	(*b)->fire = 1;
	(*b)->bomb = 1;
	(*b)->bombs_set = 0;
	(*b)->cpu = 0;
	(*b)->b_active = 0;
}

void bm_clear()
{
	free(b);
}

void bm_setsymbol(char sym)
{
	b->symbol = sym;
}

int bm_getpos()
{
	return b->pp;
}

int bm_isalive()
{
	return b->alive;
}

void bm_kill(struct bomberman * b)
{
	b->alive = 0;
}

//#endif

Added p_bman.h.



















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#ifndef __P_BMAN_H__
#define __P_BMAN_H__

typedef struct bomberman
{
	int alive; //similar to bool alive = false
	int fire; //blast radius of bombs
	int bomb; //# of bombs that can be live at once
	int bombs_set; //# of bombs currently live
	int b_active;//checks if bomb is live
	int cpu; //bool: whether or not to use ai control	
	char symbol; //what is displayed for this character
	int pp; //player position
	int bpp;//bomb position(need to access coordinates after player moves)

} bomberman;

void bm_alloc(bomberman ** b);
void bm_clear();
void bm_setsymbol(char sym);
int bm_getpos();
int bm_isalive(); //bool
void bm_kill(); //to kill a player if he is caught in a bomb blast or gets smushed by a block

#endif