-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCharacter.h
executable file
·61 lines (59 loc) · 2.21 KB
/
Character.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
#ifndef CHARACTER_H
#define CHARACTER_H
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
class Character {
public:
// constructor that creates the player
// @param maxHealth: health that character starts with
// @param damage: damage that the character can do to enemy
Character(sf::Texture & healthBarForegroundTexture, sf::Texture & healthBarBackgroundTexture, int maxHealth = 100, int damage = 10, float charSpeed = 1.5f);
// destructor
~Character();
// equal operator
// @param other: the other character to copy from
void operator=(const Character & other);
// draw the character using sfml
// @param window: the window to draw into
void draw(sf::RenderWindow & window);
// character movement
void move(const sf::RenderWindow & window, const sf::Keyboard::Key releasedKey);
// chain packets of type character
sf::Packet chainDataToPacket(sf::Packet & packet, std::string value);
// extract packets of type character
sf::Packet extractPacketToData(sf::Packet & packet);
// set isPlayer
inline void setIsPlayer(bool isPlayer) { this->isPlayer = isPlayer; }
// get position
sf::Vector2f getCenter();
// check if dead
bool getIsDead();
// get time as dead
float getTimeAsDead();
// get collision circle
sf::CircleShape getCollisionCircle();
// take damage
sf::Int16 takeDamage(sf::Int16 damage);
// get damage
sf::Int16 getDamage();
// get health
sf::Int16 getHealth();
// get playerSprite
sf::Sprite* getPlayerSprite();
// get charSpeed
float getCharSpeed();
// set position
void setPosition(sf::Vector2f position);
bool justAdded = false; // character just added to list (internet character)
protected:
sf::Sprite playerSprite; //sprite of character
float charSpeed; // normal character movement speed
sf::Int16 maxHealth, health, damage; // health and damage
bool isPlayer = false; // is the current Character the player or someone over the internet
bool isDead = false; // is player dead
private:
sf::CircleShape playerCircle = sf::CircleShape(); //circle used for player collisions
sf::Clock respawnTimer = sf::Clock(); // respawn timer
sf::Sprite healthBarForegroundSprite, healthBarBackgroundSprite; // health bar
};
#endif // !CHARACTER_H