EchoesOfFate
A game for our COMP315 Project
 
Loading...
Searching...
No Matches
Player.h
Go to the documentation of this file.
1#ifndef PLAYER_H
2#define PLAYER_H
3
4#include <SFML/Graphics.hpp>
5#include <string>
6#include <memory>
7#include <vector>
8
9#include "Map.h"
10#include "Camera.h"
11#include "Inventory.h"
12#include "Item.h"
13
14using namespace sf;
15
16class Player
17{
18 private:
19 Texture characterSpriteSheet;
20 std::vector<std::vector<Sprite>> characterStates;
21 Texture characterTexture;
22 Sprite character;
23 std::string characterTexturePath;
24 Vector2f playerVelocity;
25 float playerXRelativeToMap;
26 float playerYRelativeToMap;
27 float playerXRelativeToScreen;
28 float playerYRelativeToScreen;
29 float playerSpriteWidth;
30 float playerSpriteHeight;
31 float playerJumpHeight;
32 int playerSpriteState;
33 bool isJumping;
34 bool isFalling;
35 bool isMoving;
36 std::shared_ptr<Map> map;
37 std::shared_ptr<Camera> camera;
38 Inventory inv;
39
40 void fall(float deltaTime);
41 void jump(float deltaTime);
42 void handlePlayerMovement(float deltaTime);
43 void loadPlayerStates();
44
45 public:
46 Player(const std::string characterTexturePath, Vector2u windowSize, std::shared_ptr<Map> mapRef,
47 std::shared_ptr<Camera> cameraRef);
48 void renderPlayer(RenderWindow& window);
49 float getPlayerXRelativeToMap() const;
50 float getPlayerYRelativeToMap() const;
54 void setInventory(Inventory* inventory);
55 void update(float deltaTime);
56 const static int MAX_SLOTS = 156;
57};
58
59#endif
Definition Inventory.h:9
Inventory getInventory()
get and set inventory
Definition Player.cpp:395
static const int MAX_SLOTS
Definition Player.h:56
float getplayerSpriteWidth()
Definition Player.cpp:582
void setInventory(Inventory *inventory)
Definition Player.cpp:398
float getplayerSpriteHeight()
Definition Player.cpp:577
float getPlayerYRelativeToMap() const
Definition Player.cpp:572
float getPlayerXRelativeToMap() const
Definition Player.cpp:567
void update(float deltaTime)
Definition Player.cpp:535
void renderPlayer(RenderWindow &window)
Definition Player.cpp:562
Player(const std::string characterTexturePath, Vector2u windowSize, std::shared_ptr< Map > mapRef, std::shared_ptr< Camera > cameraRef)
Definition Player.cpp:11