-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.h
81 lines (64 loc) · 1.6 KB
/
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* @file player.h
*
* @brief class for player object
* @authors Kamil Kośnik, Adam Moszczyński
* @contact: kamilkosnik@gmail.com, adm.moszczynski@gmail.com
*
*/
#ifndef PLAYER_H
#define PLAYER_H
#include <SFML/Graphics.hpp>
#include "canNotLoadTexture.h"
class Player
{
private:
unsigned int lives = 3;
// Position of Player on the screen
sf::Vector2f mPosition;
sf::Vector2f mSize;
// Sprite of Player
sf::Sprite mSprite;
// Textures of Player
sf::Texture mTextureBack;
sf::Texture mTextureRight;
sf::Texture mTextureLeft;
sf::Texture mTextureFront;
// Which direction(s) is the player currently moving in
bool mLeftPressed;
bool mRightPressed;
bool mUpPressed;
bool mDownPressed;
// Player's speed in pixels per second
float mSpeed;
double moveWithLog = 0;
public:
// Constructor
Player();
//Set Player position
void setPosition(sf::Vector2f &pos);
// Send a copy of the sprite to main
sf::Sprite getSprite();
// Move Player in a specific direction
void moveLeft();
void moveRight();
void moveUp();
void moveDown();
// Stop Player moving in a specific direction
void stopLeft();
void stopRight();
void stopUp();
void stopDown();
unsigned int getLives() const;
unsigned int getHeight() const;
unsigned int getWidth() const;
sf::Vector2f getPosition() const;
void setLives(unsigned int newLives);
void setMoveWithLog(double speed=0);
double getMoveWithLogSpeed();
void movePositionWithLog(float elapsedTime);
// Function that is called once every frame to update display
void update(float elapsedTime);
bool die(sf::Vector2f newPos);
};
#endif