Newer
Older
#define DEACTIVATED 0
#define ACTIVATED 1
typedef enum Direction { UP, DOWN, LEFT, RIGHT, UNKNOWN } direction;
EMPTY, // unknown/unreachable
GRASS, // standard floor ' '
WALL, // (obstacle) '-' or '|' or '+'
WATER, // can be used in event to drown the player '~'
DOOR, // (obstacle) '[' or ']'
TARGET, // can be used in events 'T'
FLOORTYPE_N // last one to know how many types there are
} floortype;
typedef enum Entitytype {
FLAG, // can be used as goal '@'
SWI, // switch to activate 'O' or 'X'
MONSTER, // generic monster 'M'
NPC, // generic NPC 'A'
PUSHABLE, // (obstacle/can't walk on it) a block that can be pushed like in
// sokoban 'B'
TRAP, // an invisible trap '_',
ITEM, // generic item 'I'
ENTITY_N // last one to know how many types there are
int category; // identifier to display the tile
bool obstacle; // whether the player can move on it or not
int id; // identifier to display and use in events
int category; // used to group in events, like monster, NPC...
int *stats; // any property the entity may have (life points, state...)
char display_symbol; // The symbol of the Entity on an ASCII map
char *name; // shop, overworld, dungeon_Nth_level...
tile **floor; // immobile floor
entity *
*entities; // ennemies, NPCs, items, switches... anything used by events
int width; // map size
int height;
int player_x; // player position & direction
int player_y;
direction player_direction;
} map;
#define MAX_MAPS 256
map maps[MAX_MAPS];
int length;
} map_stack;
void init_map_stack(void);
map *load_map(const char *name, const char *data);
map *create_empty_map(const char *name, const int width, const int height);
map *unload_map(void);
int coord_idx(int y, int x);
int player_idx(void);
map *current_map(void);
void place_player(map *m, int y, int x, direction dir);
void place_entity(map *m, int y, int x, int id, int category, int *stats,
char display_symbol);
void free_map_stack(void);
bool is_obstacle(int y, int x);
// displays the current map in ASCII
void show_map(void);