#include <Configuration.h> #include <States/GameState/Entities/DynamicEntities.h> Enemy::Enemy() : m_rectangle({config::GAME_ENEMY_SIZE, config::GAME_ENEMY_SIZE}) { m_rectangle.setFillColor(config::GAME_ENEMY_COLOR); m_rectangle.setOrigin({config::GAME_ENEMY_SIZE/2, config::GAME_ENEMY_SIZE/2}); } std::unique_ptr<IDynamicEntity> Enemy::clone() const { return std::make_unique<Enemy>(*this); } void Enemy::action() { if (const auto miliseconds = static_cast<size_t>(m_stopwatch.getElapsedTime().asMilliseconds()); miliseconds < m_dist_milliseconds(m_rng)) return; const auto direction = static_cast<Room::Direction>(m_dist_direction(m_rng)); m_ptr_room->get_side(direction)->enter(this); m_stopwatch.restart(); } void Enemy::draw_into(sf::RenderWindow& window) const { window.draw(m_rectangle); } void Enemy::prepare_for_drawing() { m_rectangle.setPosition(m_ptr_room->get_position()); }