Bomberman Multiplayer
Authoritative multiplayer networking layer for Bomberman.
Loading...
Searching...
No Matches
Enemy.h
1#ifndef _BOMBERMAN_ENTITIES_ENEMY_H_
2#define _BOMBERMAN_ENTITIES_ENEMY_H_
3
4#include <utility>
5
6#include "Entities/Creature.h"
7
8namespace bomberman
9{
14 enum class AIType : int
15 {
16 Wandering,
17 Chasing
18 };
23 class Enemy : public Creature
24 {
25 public:
30 Enemy(std::shared_ptr<SDL_Texture> texture, SDL_Renderer* renderer);
37 void moveTo(const int x, const int y);
43 void moveToCell(std::pair<int, int> pathToCell);
50 bool isMovingToCell() const;
57 bool canAttack() const;
63 int getAttackRadius() const;
69 void setAIType(AIType type);
75 virtual void update(const unsigned int delta) override;
80 void generateNewPath();
81
82 private:
88 void updateMovement(const unsigned int delta);
89
90 // movement
91 float newPositionX = 0.0f; // position X to move
92 float newPositionY = 0.0f; // position Y to move
93 bool movingToCell = false; // is moving to cell
94 std::pair<int, int> path; // diff of cells to move
95 // AI
96 AIType aiType = AIType::Wandering; // AI type
97 // consts
98 const float baseSpeedTilesPerSecond = 1.8f; // tiles per second
99 const float attackSpeedTilesPerSecond = 2.5f; // tiles per second
100 const int attackRadius = 4; // attack radius (in cells)
101 // animations
102 std::shared_ptr<Animation> movement; // movement animation
103 };
104} // namespace bomberman
105
106#endif // _BOMBERMAN_ENTITIES_ENEMY_H_
Creature class.
Definition Creature.h:13
Enemy class.
Definition Enemy.h:24
bool isMovingToCell() const
Return is enemy moving to cell or not.
Definition Enemy.cpp:59
int getAttackRadius() const
Get the Attack Radius of enemy.
Definition Enemy.cpp:69
void generateNewPath()
Generate new path if enemy finish movement.
Definition Enemy.cpp:128
void moveToCell(std::pair< int, int > pathToCell)
Move enemy for specified diff of cells.
Definition Enemy.cpp:47
void setAIType(AIType type)
Set AI type.
Definition Enemy.cpp:74
bool canAttack() const
Can enemy attack.
Definition Enemy.cpp:64
void moveTo(const int x, const int y)
Move enemy to specified position.
Definition Enemy.cpp:28
virtual void update(const unsigned int delta) override
Update movement of enemy.
Definition Enemy.cpp:79