dungeon/src/Entity.h

32 lines
850 B
C
Raw Normal View History

2018-01-09 21:59:05 +01:00
#pragma once
2017-09-26 15:49:11 +02:00
#include "vec2i.h"
#include "Color.h"
2017-09-26 15:49:11 +02:00
class Tilemap;
enum EntityTypes {
ENTITY_BASE, // All entities are objects that can be placed on the map and can be interacted with
ENTITY_ACTOR, // Actors are characters with AI or controlled by the player
ENTITY_ITEM, // Items can be picked up
};
class Entity {
vec2i position;
protected:
unsigned int sprite_id;
Color sprite_color;
2017-09-26 15:49:11 +02:00
bool collision;
public:
2018-01-09 21:59:05 +01:00
Entity(vec2i pos);
2017-09-26 15:49:11 +02:00
vec2i get_position();
bool has_collision();
2018-01-09 21:59:05 +01:00
bool move(int dx, int dy, Tilemap* map); // returns false if movement failed
bool move(vec2i dpos, Tilemap* map);
2017-09-26 15:49:11 +02:00
void set_position(vec2i pos);
unsigned int get_sprite_id() { return sprite_id; };
Color get_sprite_color() { return sprite_color; };
2017-09-26 15:49:11 +02:00
virtual EntityTypes entity_type() { return ENTITY_BASE; };
};