-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.h
124 lines (110 loc) · 3.16 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef PLAYER_H
#define PLAYER_H
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>
#include "Tile.h"
#include "MyTexture.h"
#include "Renderable.h"
#include "MyWindow.h"
#include "SoundEffect.h"
#include "Timer.h"
#include "utilities.h"
#include <string>
#include "Animation.h"
class LGame;
class Player : public Renderable
{
public:
// Initializes the variables
Player(LTexture &myTexture, LTexture &yuluTexture, LGame &game, int playerHeight, int playerWidth, int right, int left, int top, int bottom);
// Takes key presses and adjusts the dot's velocity
void handleEvent(SDL_Event &e);
// void handleEventMoving(SDL_Event &e) ;
// Moves the dot and check collision against tiles
void move();
void moveBy(int offsetX, int offsetY);
// Centers the camera over the dot
void setCamera(SDL_Rect &camera);
void setVelocity(int vel);
// Shows the dot on the screen
int render(SDL_Renderer *renderer, SDL_Rect &camera);
// int renderMoving(SDL_Renderer *renderer, SDL_Rect &camera);
void cleanUp();
SDL_Rect getBox();
int getXVel();
int getYVel();
int getMoveFactor();
int getHealth();
int getMoney();
int getPoints();
void setHealth(float h);
void setPoints(int p);
void setMoney(int m);
void setMoveFactor(int factor);
void setCoords(int x, int y);
void setVel(int velX, int velY);
void update();
void toggleYulu();
LGame &getGame();
void setLastTileType(int tileType);
int getLastTileType();
std ::string getHostelName();
void resetHealth();
bool hasYulu();
LTimer &getCurrentTaskTimer();
int getCurrentTaskTime();
void setCurrentTaskTime(int t);
bool isBusy();
void updateStateParameters(playerStateUpdate s);
void setUpdateStateParameters(playerStateUpdate s);
void changeStateParameters(playerStateUpdate s);
bool hadLunch();
bool hadBreakFast();
bool hadDinner();
void setBreakfast(bool b);
void setLunch(bool l);
void setDinner(bool d);
std ::string getTaskText();
void setTaskText(std::string s);
void setTaskAnimation(Animation *a);
int music = 0;
void resetPlayer();
private:
// Collision box of the dot
LGame &mGame;
SDL_Rect mBox;
LTexture &mTexture;
LTexture &yuluTexture;
Animation *taskAnimation;
bool hasTaskAnimation;
// bool touchesWall(std::vector<Tile> tiles);
int playerHeight, playerWidth;
int right, top, left, bottom;
int mframes;
char direction;
int numOfAnimationImages;
int animationSpeed = 12;
int money, points;
float health;
std ::string hostelName;
std::vector<SDL_Rect> playerImages;
// Maximum axis velocity of the dot
int velocity;
int moveFactor;
// The velocity of the dot
int mVelX, mVelY;
int lastTileType = -1;
LTimer yuluTimer;
LTimer healthTimer;
LTimer currentTaskTimer;
int currentTaskTime;
playerStateUpdate updateState;
bool breakfast, lunch, dinner;
std::string taskText;
Mix_Chunk *mCollisionMusic;
Mix_Chunk *mMovementMusic;
Mix_Chunk *mGrassMusic;
Mix_Chunk *mTaskCompleteMusic;
};
#endif