2017-12-01 16:03:19 +01:00
|
|
|
#ifndef MAP_H_
|
|
|
|
#define MAP_H_
|
|
|
|
|
|
|
|
#include <SDL2/SDL.h>
|
2017-12-05 08:13:28 +01:00
|
|
|
#include <stdbool.h>
|
2017-12-01 16:03:19 +01:00
|
|
|
|
2017-12-19 09:06:21 +01:00
|
|
|
#include "hashtable.h"
|
|
|
|
#include "linkedlist.h"
|
2017-12-01 16:03:19 +01:00
|
|
|
#include "sprite.h"
|
|
|
|
#include "camera.h"
|
2017-12-02 16:24:31 +01:00
|
|
|
#include "position.h"
|
2017-12-08 14:40:33 +01:00
|
|
|
#include "timer.h"
|
2017-12-05 15:03:20 +01:00
|
|
|
#include "defines.h"
|
2017-12-13 14:26:30 +01:00
|
|
|
#include "monster.h"
|
2017-12-01 16:03:19 +01:00
|
|
|
|
2017-12-05 15:03:20 +01:00
|
|
|
typedef struct MapTile_t {
|
2017-12-08 14:40:33 +01:00
|
|
|
int textureIndex0;
|
|
|
|
int textureIndex1;
|
2017-12-02 23:32:40 +01:00
|
|
|
SDL_Rect clip;
|
2017-12-05 08:13:28 +01:00
|
|
|
bool collider;
|
2017-12-10 19:51:24 +01:00
|
|
|
bool lightsource;
|
2017-12-22 06:27:58 +01:00
|
|
|
bool levelExit;
|
2017-12-02 16:24:31 +01:00
|
|
|
} MapTile;
|
|
|
|
|
2017-12-05 15:03:20 +01:00
|
|
|
typedef struct Room_t {
|
2017-12-05 08:13:28 +01:00
|
|
|
MapTile* tiles[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
|
2017-12-08 14:40:33 +01:00
|
|
|
MapTile* secondary_tiles[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
|
2017-12-08 09:45:57 +01:00
|
|
|
MapTile* decorations[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
|
2017-12-01 16:03:19 +01:00
|
|
|
} Room;
|
|
|
|
|
2017-12-05 15:03:20 +01:00
|
|
|
typedef struct Map_t {
|
2017-12-05 08:13:28 +01:00
|
|
|
Room* rooms[MAP_H_ROOM_COUNT][MAP_V_ROOM_COUNT];
|
2017-12-02 16:24:31 +01:00
|
|
|
LinkedList *textures;
|
2017-12-13 14:26:30 +01:00
|
|
|
Hashtable *monsterTextures;
|
|
|
|
LinkedList *monsters;
|
2017-12-01 16:03:19 +01:00
|
|
|
Position currentRoom;
|
2017-12-08 14:40:33 +01:00
|
|
|
Timer *renderTimer;
|
2017-12-01 16:03:19 +01:00
|
|
|
int level;
|
|
|
|
} Map;
|
|
|
|
|
2017-12-19 21:00:02 +01:00
|
|
|
Map* map_create(void);
|
2017-12-02 23:32:40 +01:00
|
|
|
|
|
|
|
int map_add_texture(Map*, const char *path, SDL_Renderer*);
|
|
|
|
|
2017-12-05 08:13:28 +01:00
|
|
|
void map_add_tile(Map *map, Position *tile_pos, MapTile*);
|
2017-12-01 16:03:19 +01:00
|
|
|
|
2017-12-08 09:45:57 +01:00
|
|
|
void map_add_decoration(Map *map, Position *tile_pos, MapTile*);
|
|
|
|
|
2017-12-13 23:20:54 +01:00
|
|
|
Texture* map_add_monster_texture(Map*, const char *path, SDL_Renderer*);
|
2017-12-13 20:31:04 +01:00
|
|
|
|
|
|
|
void map_add_monster(Map*, Monster*);
|
|
|
|
|
2017-12-17 13:43:41 +01:00
|
|
|
void map_move_monsters(Map*, RoomMatrix*);
|
|
|
|
|
|
|
|
void map_clear_dead_monsters(Map*);
|
|
|
|
|
2017-12-01 16:03:19 +01:00
|
|
|
void map_render(Map*, Camera*);
|
|
|
|
|
2017-12-03 11:09:57 +01:00
|
|
|
void map_set_current_room(Map*, Position*);
|
|
|
|
|
2017-12-01 16:03:19 +01:00
|
|
|
void map_destroy(Map*);
|
|
|
|
|
|
|
|
#endif // MAP_H_
|