dungeon/src/Tilemap.h

45 lines
1.3 KiB
C
Raw Permalink Normal View History

2017-09-17 13:43:13 +02:00
#pragma once
#include <array>
2017-09-17 13:43:13 +02:00
#include <vector>
2017-12-31 21:51:57 +01:00
#include "SpriteAtlas.h"
#include "Actor.h"
2018-01-09 21:59:05 +01:00
#include "TileSet.h"
2017-09-17 13:43:13 +02:00
struct vec2i;
class Renderer;
class FieldOfView;
2017-09-17 13:43:13 +02:00
class Tilemap {
2018-01-09 21:59:05 +01:00
std::vector<std::string> tilemap;
std::vector<Actor*> actors;
2017-09-17 13:43:13 +02:00
int width;
int height;
public:
2018-01-09 21:59:05 +01:00
Tilemap(TileSet tileset = TileSet(), int width = 1, int height = 1);
TileSet tiles;
2017-09-17 13:43:13 +02:00
~Tilemap();
int get_width();
int get_height();
int get_index(int x, int y); // Converts [x,y] to a 1D index.
bool is_inside_bounds(int x, int y);
std::vector<vec2i> get_neighbours(int x, int y, int range = 1);
std::vector<vec2i> get_neighbours(int x, int y, int up, int down, int left, int right);
2018-01-09 21:59:05 +01:00
void set_tile(int x, int y, std::string tile); // "Tile" is inteded for tile ids, but can be anything really.
std::string get_tile_id(int x, int y);
Tile const& get_tile(int x, int y);
bool is_blocked(int x, int y); // Checks if there is an actor blocking the tile.
2017-09-17 13:43:13 +02:00
2017-12-31 21:51:57 +01:00
void draw(Renderer *renderer, SpriteAtlas *tileset, int x, int y, int tx, int ty, int tw, int th, FieldOfView* view);
void add_actor(Actor *actor);
void remove_actor(Actor *actor);
void debug_print();
2018-01-09 21:59:05 +01:00
Actor* get_actor(int x, int y);
std::vector<Actor*> get_actors(int x, int y, int range);
std::vector<Actor*>* get_actor_list();
2017-12-31 21:51:57 +01:00
void delete_actors();
2017-09-17 13:43:13 +02:00
};