#include "Entity.h" #include "../Environment/Maze.h" namespace game { Entity::Entity(PositionVector starting_position, char display_character): pos(starting_position), display_character(display_character), move_left(true){} bool Entity::is_at_position(const PositionVector& position) const { return this->pos.eq(position); } void Entity::tick(Maze& maze, const PositionVector& player_position){ switch (this->display_character) { case 'A': // No thoughts, head empty :P return; case 'B': this->handle_bowie(maze); return; case 'C': this->handle_connelly(maze, player_position); return; default: return; } } void Entity::handle_bowie(Maze& maze) { PositionVector target_position = {this->pos.x, this->pos.y}; if (this->move_left) target_position.change_x(-1); else target_position.change_x(1); if (maze.is_pos_free(target_position, false)) this->pos = target_position; else this->move_left = !this->move_left; } void Entity::handle_connelly(Maze& maze, const PositionVector& player_position) { PositionVector diff = maze.get_distance_pos1_pos2(player_position, this->pos); PositionVector normalized_diff = {diff.x, diff.y}; normalized_diff.normalize(); PositionVector target_position = {this->pos.x, this->pos.y}; } char Entity::get_display_character() { return this->display_character; } }