-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.h
65 lines (44 loc) · 879 Bytes
/
Player.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef PLAYER_H
#define PLAYER_H
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/Sprite.hpp>
#include "AnimationHolder.h"
class Window;
class World;
enum class etPlayerState
{
eStay,
eRun,
eJump
};
class Player
{
public:
Player(const World* pWorld);
void SetTexture(sf::Texture& texture);
void Update(float time);
void MoveLeft();
void MoveRight();
void Jump();
void SetOffset(float x, float y);
void Draw(::Window& window);
bool IsOnGround() const { return onGround; }
sf::FloatRect GetRect() const { return rect; }
protected:
bool onGround;
float dx;
float dy;
float curFrame;
sf::FloatRect rect;
AnimationHolder animation;
//AnimationHolderT<PlayerState> animation;
etPlayerState playerState;
private:
void CollisionX();
void CollisionY();
private:
const World* pWorld;
float offsetX = 0;
float offsetY = 0;
};
#endif