breakhack/src/map.h

119 lines
2.4 KiB
C
Raw Normal View History

2018-02-16 18:11:26 +01:00
/*
* BreakHack - A dungeone crawler RPG
* Copyright (C) 2018 Linus Probert <linus.probert@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2017-12-01 16:03:19 +01:00
#ifndef MAP_H_
#define MAP_H_
2018-02-21 00:29:21 +01:00
#include <SDL.h>
2017-12-05 08:13:28 +01:00
#include <stdbool.h>
2017-12-01 16:03:19 +01:00
#include "linkedlist.h"
2017-12-01 16:03:19 +01:00
#include "sprite.h"
#include "camera.h"
#include "position.h"
2017-12-08 14:40:33 +01:00
#include "timer.h"
#include "defines.h"
#include "monster.h"
#include "player.h"
2018-03-15 11:30:18 +01:00
#include "map_room_modifiers.h"
2018-08-13 13:11:32 +02:00
#include "object.h"
2017-12-01 16:03:19 +01:00
typedef struct UpdateData UpdateData;
typedef struct Trap Trap;
2018-05-15 11:16:56 +02: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;
bool lethal;
2017-12-10 19:51:24 +01:00
bool lightsource;
2017-12-22 06:27:58 +01:00
bool levelExit;
} MapTile;
typedef struct Room_t {
2017-12-05 08:13:28 +01:00
MapTile* tiles[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
2017-12-08 09:45:57 +01:00
MapTile* decorations[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
Trap* traps[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
2018-03-15 11:30:18 +01:00
RoomModifierData modifier;
2018-08-21 15:44:12 +02:00
bool visited;
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;
LinkedList *monsters;
LinkedList *items;
LinkedList *artifacts;
2018-08-13 13:11:32 +02:00
LinkedList *objects;
2017-12-01 16:03:19 +01:00
Position currentRoom;
2017-12-08 14:40:33 +01:00
Timer *renderTimer;
2018-02-19 15:09:04 +01:00
Timer *monsterMoveTimer;
2017-12-01 16:03:19 +01:00
int level;
} Map;
2018-02-19 15:09:04 +01:00
Map*
map_create(void);
2017-12-02 23:32:40 +01:00
MapTile *
map_create_tile(void);
2018-02-19 15:09:04 +01:00
int
map_add_texture(Map*, const char *path, SDL_Renderer*);
2017-12-02 23:32:40 +01:00
2018-02-19 15:09:04 +01:00
void
map_add_tile(Map *map, Position *tile_pos, MapTile*);
2017-12-01 16:03:19 +01:00
2018-02-19 15:09:04 +01:00
void
map_add_decoration(Map *map, Position *tile_pos, MapTile*);
2017-12-08 09:45:57 +01:00
void
map_add_trap(Map*, Position*, Trap*);
2018-02-19 15:09:04 +01:00
void
map_add_monster(Map*, Monster*);
2018-02-19 15:09:04 +01:00
bool
map_move_monsters(Map*, RoomMatrix*);
2017-12-17 13:43:41 +01:00
2018-09-13 08:05:17 +02:00
bool
2018-08-13 13:11:32 +02:00
map_clear_expired_entities(Map*, Player*);
2017-12-17 13:43:41 +01:00
2018-02-19 15:09:04 +01:00
void
2018-08-13 13:11:32 +02:00
map_on_new_turn(Map*);
2018-05-15 11:16:56 +02:00
void
map_update(UpdateData*);
2018-05-15 11:16:56 +02:00
2018-02-19 15:09:04 +01:00
void
map_render(Map*, Camera*);
2017-12-01 16:03:19 +01:00
void
map_render_mid_layer(Map*, Camera*);
void
map_render_top_layer(Map*, RoomMatrix*, Camera*);
2018-02-19 15:09:04 +01:00
void
map_set_current_room(Map*, Position*);
2017-12-03 11:09:57 +01:00
2018-02-19 15:09:04 +01:00
void
map_destroy(Map*);
2017-12-01 16:03:19 +01:00
#endif // MAP_H_