Adrian Hedqvist
ec131d8bda
* Implemented lua using kaguya, only for config files for now * Moved color struct to its own header * statically link glew instead of including the source in the project * Other stuff that I don't remember
43 lines
728 B
C++
43 lines
728 B
C++
//
|
|
// Created by Adrian on 2017-09-25.
|
|
//
|
|
|
|
#include "Entity.h"
|
|
#include "Tilemap.h"
|
|
|
|
Entity::Entity(Tilemap *map, vec2i pos) {
|
|
this->map = map;
|
|
position = pos;
|
|
collision = false;
|
|
sprite_id = '?';
|
|
}
|
|
|
|
vec2i Entity::get_position() {
|
|
return position;
|
|
}
|
|
|
|
bool Entity::move(vec2i dpos) {
|
|
return move(dpos.x, dpos.y);
|
|
}
|
|
|
|
bool Entity::move(int dx, int dy) {
|
|
vec2i newpos = position + vec2i(dx, dy);
|
|
if (!collision || !map->IsBlocked(newpos.x, newpos.y)) {
|
|
position = newpos;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void Entity::set_position(vec2i pos) {
|
|
position = pos;
|
|
}
|
|
|
|
Tilemap *Entity::get_map() {
|
|
return map;
|
|
}
|
|
|
|
bool Entity::has_collision() {
|
|
return collision;
|
|
}
|