-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmap.h
68 lines (54 loc) · 1.56 KB
/
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
#ifndef map_h
#define map_h
#include <stdint.h>
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_image.h>
#include "utility.h"
// IF YOU WANT TO INCREASE YOUR MAP SIZE OR ENEMY SIZE MAKE SURE TO INCREASE DEFINE VARIABLE BELOW IF IT EXCEED THE MAXIMUM
#define MAX_MAP_ROW 100
#define MAX_MAP_COL 100
#define MAX_ENEMY_SPAWN 100
/*
Map Tiles type
Hint : Some type might need a background, to configure it try to modify "get_map_offset(Map * map)"
*/
typedef enum _BLOCK_TYPE{
FLOOR,
WALL,
DOOR_CLOSE,
HOLE,
COIN,
NOTHING
} BLOCK_TYPE;
typedef enum _COIN_STATUS {
APPEAR,
DISAPPEARING,
DISAPPEAR
} COIN_STATUS;
// Map Struct
typedef struct Map_{
uint8_t ** map; // Map array
Point ** offset_assets; // Assets
int row, col;
// Map assets
ALLEGRO_BITMAP* assets;
ALLEGRO_BITMAP* coin_assets;
// Coin Properties
ALLEGRO_SAMPLE* coin_audio;
// Spawn Coordinate
Point Spawn;
Point EnemySpawn[MAX_ENEMY_SPAWN];
char EnemyCode[MAX_ENEMY_SPAWN];
uint8_t EnemySpawnSize;
} Map;
/*
MAP FUNCTION
Feel free to add more if you have some idea or interaction with the map
*/
Map create_map(char * path, uint8_t type); // Create a map based on given file path
void draw_map(Map * map, Point cam); // Draw the map
void update_map(Map * map, Point player_coord, int * total_coins); // Update map : you might want add some parameter here
void destroy_map(Map * map); // Destroy map
bool isWalkable(BLOCK_TYPE block);
#endif /* map_h */