breakhack/src/map.h

107 lines
2.2 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"
2017-12-01 16:03:19 +01:00
struct UpdateData;
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];
2018-03-15 11:30:18 +01:00
RoomModifierData modifier;
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;
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
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-02-19 15:09:04 +01:00
void
map_clear_dead_monsters(Map*, Player*);
2017-12-17 13:43:41 +01:00
2018-02-19 15:09:04 +01:00
void
map_clear_collected_items(Map*);
2018-05-15 11:16:56 +02:00
void
map_update(struct 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_top_layer(Map*, 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_