dungeon/src/Tilemap.h

39 lines
1.1 KiB
C
Raw Normal View History

2017-09-17 13:43:13 +02:00
#pragma once
#include <vector>
#include "Tileset.h"
2017-09-26 15:49:11 +02:00
#include "Entity.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 {
unsigned int* tilemap;
2017-09-26 15:49:11 +02:00
std::vector<Entity*> entities;
2017-09-17 13:43:13 +02:00
int width;
int height;
public:
Tilemap(int width = 1, int height = 1);
~Tilemap();
int GetWidth();
int GetHeight();
int GetIndex(int x, int y); // Converts [x,y] to a 1D index.
bool IsInsideBounds(int x, int y);
std::vector<vec2i> getNeighbours(int x, int y, int range = 1);
2017-09-26 15:49:11 +02:00
void set_tile(int x, int y, unsigned int tile); // "Tile" is inteded for tile ids, but can be anything really.
2017-09-17 13:43:13 +02:00
int GetTile(int x, int y);
bool IsBlocked(int x, int y); // Checks if there is an actor blocking the tile.
2017-09-23 22:06:36 +02:00
void draw(Renderer *renderer, Tileset *tileset, int x, int y, int tx, int ty, int tw, int th, FieldOfView* view);
2017-09-26 15:49:11 +02:00
void add_entity(Entity *actor);
void remove_entity(Entity *actor);
void debug_print();
2017-09-26 15:49:11 +02:00
Entity* get_entity(int x, int y, EntityTypes type);
std::vector<Entity*> get_entities(int x, int y, int range, EntityTypes type);
std::vector<Entity*>* get_entity_list();
2017-09-17 13:43:13 +02:00
};