LI2 Roguelite
map.h
Go to the documentation of this file.
1 #ifndef _MAP_H_
2 #define _MAP_H_
3 
4 typedef struct state State;
5 typedef struct cell Cell;
6 typedef struct item Item;
7 typedef struct player Player;
8 typedef struct projectile Projectile;
9 typedef struct monster Monster;
10 
26 typedef struct map {
27  int width;
28  int height;
29  Cell ***cells;
30 
31  int has_menu;
32 
34  int nr_items;
35 
38 } Map;
39 
40 Map *initMap(int width, int height);
41 void freeMap(void *p);
42 
43 void drawMap(Map *map, int mode);
44 
45 void generateMap(State *st);
46 
47 void getPlayerInitialPosition(Map *map, int *x, int *y);
48 void getRandomCoordinates(Map* map, int* x, int* y);
49 
50 void calculateDistances(Map* map, int x, int y);
52 
53 void distributeItems(Map* map, Item** items, int nr_items);
54 void pickUpItem(State *st);
55 
57 
58 #endif
void drawMap(Map *map, int mode)
Draw the map according to the mode.
Definition: map.c:233
void getPlayerInitialPosition(Map *map, int *x, int *y)
Get the player initial (3x3 empty space)
Definition: map.c:292
void calculateVision(Map *map, Player *player)
Calculate the vision of the player and updates the is_visible and was_visible field in the cells.
Definition: map.c:457
void getRandomCoordinates(Map *map, int *x, int *y)
Get random coordinates for monsters.
Definition: map.c:326
void generateMap(State *st)
Generate the map based on algorithm TODO explain more.
Definition: map.c:138
void distributeItems(Map *map, Item **items, int nr_items)
Distribute the items on the map.
Definition: map.c:485
struct map Map
Structure that represents a map in the game.
void pickUpItem(State *st)
Get the item on the player position.
Definition: map.c:523
void freeMap(void *p)
Free the map structure.
Definition: map.c:83
Map * initMap(int width, int height)
Initialize a new map.
Definition: map.c:27
Monster * getCloserUnhurtMonster(State *st)
Get the closer unhurt monster to the player.
Definition: map.c:587
void calculateDistances(Map *map, int x, int y)
Calculate the distances from the player to all the cells, also updates the effect and effect_duration...
Definition: map.c:349
Structure of a cell.
Definition: cell.h:27
Item structure represents an item in the game.
Definition: item.h:28
Structure that represents a map in the game.
Definition: map.h:26
int width
Definition: map.h:27
Cell *** cells
Definition: map.h:29
Item ** items
Definition: map.h:33
int height
Definition: map.h:28
int nr_projectiles
Definition: map.h:37
Projectile ** projectiles
Definition: map.h:36
int nr_items
Definition: map.h:34
int has_menu
Definition: map.h:31
Structure of a monster.
Definition: monster.h:28
Structure of a player.
Definition: player.h:53
(private) Structure of a thrown projectile
Definition: combat.c:24
Sructure of the game state.
Definition: state.h:38