-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.h
54 lines (39 loc) · 990 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
#pragma once
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include "utils.h"
class Player
{
private:
// variables
sf::Texture texture;
sf::Sprite sprite;
sf::IntRect currentFrame;
sf::Clock animationTimer;
float movementSpeed;
float cooldownAttack;
float cooldownAttackMax;
int lives;
State state;
// private functions
void initVariables();
void initTexture();
void initSprite();
public:
Player();
virtual ~Player();
// accessors
const sf::Vector2f& getPosition() const;
const sf::FloatRect getBounds() const;
const int getNumLives() const { return this->lives; }
// modifiers
void setPosition(const float x, const float y);
// public functions
const bool canAttack();
void movePlayer(const float dirX, const float dirY);
void setState(State state) { this->state = state; }
void updateAttackCooldown();
void update();
void render(sf::RenderTarget& target);
};