Commit 340c5a84 authored by Сулимов Игорь Андреевич's avatar Сулимов Игорь Андреевич
Browse files

T

parent 29a1d505
No related merge requests found
Showing with 26 additions and 5 deletions
+26 -5
......@@ -19,7 +19,8 @@ add_executable(pac-man
"source/Commands/ExitCommand.cpp"
"source/Commands/GameCommand.cpp"
"source/Maze_Content/Buildings/Room.cpp"
"source/Maze_Content/Entities/Pacman.cpp"
"source/Maze_Content/Entities/DynamicEntities/Enemy.cpp"
)
target_compile_definitions(pac-man PRIVATE
......
#pragma once
class GameContext {
public:
public:
};
\ No newline at end of file
......@@ -6,7 +6,7 @@ class Enemy: public IDynamicEntity {
public:
void prepare_for_drawing() override; ///@todo
void draw_into(sf::RenderWindow& window) const override; ///@todo
std::unique_ptr<IDynamicEntity> clone() override; ///@todo
std::unique_ptr<IDynamicEntity> clone() const override; ///@todo
void action() override; ///@todo
public:
Enemy(); ///@todo
......
......@@ -4,7 +4,7 @@
class IDynamicEntity: public IEntity {
public:
virtual std::unique_ptr<IDynamicEntity> clone() = 0;
virtual std::unique_ptr<IDynamicEntity> clone() const = 0;
virtual void action() = 0;
virtual ~IDynamicEntity() = default;
};
\ No newline at end of file
......@@ -4,6 +4,6 @@
class IStaticEntity: public IEntity {
public:
virtual std::unique_ptr<IStaticEntity> clone() = 0;
virtual std::unique_ptr<IStaticEntity> clone() const = 0;
virtual ~IStaticEntity() = default;
};
\ No newline at end of file
#include "MazeContent/Entities/DynamicEntities/Enemy.h"
std::unique_ptr<IDynamicEntity> Enemy::clone() const {
return std::make_unique<Enemy>(*this);
}
void Enemy::action() {
auto miliseconds = static_cast<size_t>(m_stopwatch.getElapsedTime().asMilliseconds());
if (miliseconds < rand() % 10000)
return;
auto direction = static_cast<Room::Direction>(rand() % 4);
m_ptr_room->get_side(direction)->enter(this);
m_stopwatch.restart();
}
\ No newline at end of file
#include "MazeContent/Entities/Pacman.h"
void Pacman::move(Room::Direction direction) {
m_location->get_side(direction)->enter(this);
m_ptr_room->get_side(direction)->enter(this);
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment