mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#ifndef PLATFORMSTARTERKIT_ENEMY_HPP
|
|
#define PLATFORMSTARTERKIT_ENEMY_HPP
|
|
|
|
#include "headers.hpp"
|
|
#include "animation.hpp"
|
|
|
|
namespace PlatformerStarterKit {
|
|
//Facing direction along the X axis.
|
|
enum class FaceDirection {
|
|
Left = -1,
|
|
Right = 1,
|
|
};
|
|
|
|
class Level;
|
|
|
|
// A monster who is impeding the progress of our fearless adventurer.
|
|
class Enemy {
|
|
public:
|
|
Enemy(xna::sptr<PlatformerStarterKit::Level> const& level, xna::Vector2 const& position, xna::String const& spriteSet);
|
|
|
|
public:
|
|
xna::sptr<PlatformerStarterKit::Level> Level() const;
|
|
|
|
constexpr xna::Vector2 Position() const {
|
|
return position;
|
|
}
|
|
|
|
xna::Rectangle BoundingRectangle() const;
|
|
|
|
void LoadContent(xna::String const& spriteSet);
|
|
void Update(xna::GameTime const& gameTime);
|
|
void Draw(xna::GameTime const& gameTime, xna::SpriteBatch& spriteBatch);
|
|
|
|
private:
|
|
static constexpr float MaxWaitTime = 0.5f;
|
|
static constexpr float MoveSpeed = 128.0f;
|
|
|
|
xna::sptr<PlatformerStarterKit::Level> level;
|
|
xna::Vector2 position{};
|
|
xna::Rectangle localBounds{};
|
|
|
|
xna::sptr<Animation> runAnimation = nullptr;
|
|
xna::sptr<Animation> idleAnimation = nullptr;
|
|
AnimationPlayer sprite{};
|
|
FaceDirection direction = FaceDirection::Left;
|
|
|
|
float waitTime = 0.0F;
|
|
};
|
|
}
|
|
|
|
#endif |