-
Notifications
You must be signed in to change notification settings - Fork 0
/
CharacterTopDown.h
49 lines (38 loc) · 1.07 KB
/
CharacterTopDown.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <SFML/Graphics.hpp>
#include <vector>
#include <memory>
#include "AnimationHandler.h"
#include "ITile.h"
enum class MapDirection
{
LEFT,
UP,
RIGHT,
DOWN
};
class CharacterTopDown : public ITile
{
public:
void SetPosition(const sf::Vector2f &pos);
void AddAnim(Animation &anim) override;
sf::RectangleShape *Get(float dt) override;
// For top-down single character
CharacterTopDown(const sf::Vector2f &size, sf::Texture *stand, int zLevel) : m_IsMoving(false)
{
m_Shape.setSize(size);
m_StandSprites.emplace_back(stand);
ZLevel = zLevel;
// Move the origin to the center of the object for trafos
m_Shape.setOrigin(size.x / 2.0, size.y / 2.0);
}
void Turn(float deg);
void Move(MapDirection dir); //(const sf::Vector2f& relativeDist)
sf::Vector2f GetPosition();
void SetRotation(float deg);
private:
// MapDirection m_CurrentDirection;
// Single sprite, rotate the sprite for movement
std::vector<sf::Texture *> m_StandSprites;
bool m_IsMoving;
};