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
|
|
|
#include <linkedlist.h>
|
|
|
|
|
|
|
|
#include "sprite.h"
|
|
|
|
#include "camera.h"
|
2017-12-02 16:24:31 +01:00
|
|
|
#include "position.h"
|
2017-12-01 16:03:19 +01:00
|
|
|
|
|
|
|
#define MAP_ROOM_HEIGHT 12
|
|
|
|
#define MAP_ROOM_WIDTH 16
|
|
|
|
#define MAP_V_ROOM_COUNT 10
|
|
|
|
#define MAP_H_ROOM_COUNT 10
|
2017-12-03 11:09:57 +01:00
|
|
|
#define TILE_DIMENSION 64
|
2017-12-01 16:03:19 +01:00
|
|
|
|
|
|
|
typedef struct {
|
2017-12-02 16:24:31 +01:00
|
|
|
unsigned int textureIndex;
|
2017-12-02 23:32:40 +01:00
|
|
|
SDL_Rect clip;
|
2017-12-05 08:13:28 +01:00
|
|
|
bool collider;
|
2017-12-02 16:24:31 +01:00
|
|
|
} MapTile;
|
|
|
|
|
|
|
|
typedef struct {
|
2017-12-05 08:13:28 +01:00
|
|
|
MapTile* tiles[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
|
2017-12-01 16:03:19 +01:00
|
|
|
} Room;
|
|
|
|
|
|
|
|
typedef struct {
|
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-01 16:03:19 +01:00
|
|
|
Position currentRoom;
|
|
|
|
int level;
|
|
|
|
} Map;
|
|
|
|
|
2017-12-02 23:32:40 +01:00
|
|
|
Map* map_create();
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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_
|