-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGameState.hpp
84 lines (62 loc) · 1.66 KB
/
GameState.hpp
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
#ifndef GAMESTATE_HPP_INCLUDED
#define GAMESTATE_HPP_INCLUDED
#include "State.hpp"
#include "Texture.hpp"
#include "World.hpp"
#include "Entity.hpp"
#include <vector>
enum GameDirection {
DIR_UP,
DIR_DOWN,
DIR_LEFT,
DIR_RIGHT
};
class GameState : public State {
static GameState instance;
World world;
//double playerX = 10, playerY = 10;
Entity player = { 0, 0, 4, 4};
std::vector<Game::Rect> frames = {
{0, 0, 4, 5},
{0, 5, 4, 5},
{0, 10, 4, 5},
{0, 15, 4, 5},
{0, 20, 4, 5},
{0, 25, 4, 5}
};
int currentFrame = 0;
Game::Texture playerImg;
Game::Texture blocks;
bool up = false,
down = false,
left = false,
right = false,
jump = false,
mouseLeft = false,
mouseRight = false;
int mouseX, mouseY;
float xVel = 0.0f, yVel = 0.0f;
float acc = 0.05f;
float xMaxVel = 1.0f, yMaxVel = 3.0f;
float gravity = 0.05f;
float jumpForce = 1.0f;
bool touchingGround = false;
int camX, camY;
public:
void cleanup();
void handleKeyDown(WORD keyCode);
void handleKeyUp(WORD keyCode);
void handleMouseEvent(MOUSE_EVENT_RECORD* event);
void update();
void render(Game::Display& display);
static GameState* Instance() {
return &instance;
}
// if move is true, the entity will be moved
// outside of the block it's touching based on its direction
bool handleCollision(Entity* e, bool move = false, GameDirection dir = DIR_UP);
protected:
GameState() {}; // protected constructor for singleton
void setup();
};
#endif // GAMESTATE_HPP_INCLUDED