breakhack/src/map.h

51 lines
1018 B
C
Raw Normal View History

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"
#include "position.h"
2017-12-08 14:40:33 +01:00
#include "timer.h"
#include "defines.h"
2017-12-01 16:03:19 +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;
} MapTile;
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;
typedef struct Map_t {
2017-12-05 08:13:28 +01:00
Room* rooms[MAP_H_ROOM_COUNT][MAP_V_ROOM_COUNT];
LinkedList *textures;
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-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
2017-12-08 09:45:57 +01:00
void map_add_decoration(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_