-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.h
93 lines (79 loc) · 1.95 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
#ifndef __Player__
#define __Player__
//#include "PhysicsManager.h"
struct Vec {
float x, y;
};
struct Position {
int x, y;
};
struct Bounds {
int up, down, left, right;
};
class Player {
public:
Player();
~Player();
void tick();
enum MovementState{Idle, Walking, Running};
enum AirState { Grounded, Jumping, Airborne, Falling, MaxFalling, Landing };
//enum AirState{FreeFalling, MaxFalling};
void init(float x, float y);
void setPosition(float x, float y);
void movePosition(float x, float y);
//void setYSpeed(float speed);
Vec *getNextPos();
float getNextXPos();
float getNextYPos();
Vec *getPrevPos();
float getPrevXPos();
float getPrevYPos();
Bounds getNextBounds();
Bounds getPrevBounds();
int getBBoxSizeX();
int getBBoxSizeY();
void isOnGround(bool b);
float getXSpeed();
float getYSpeed();
void left();
void right();
void up();
void down();
void action();
void jump();
//Positive is Right and Down
private:
Vec velocity;
float ySpeed = 0.0;
float xSpeed = 0.0;
bool isJumping();
bool isJmping = false;
bool onGround = false;
bool facingRight = true;
MovementState xState = Idle;
AirState yState = Grounded;
/*Constants*/
const float xAccel = 0.046875;
const float xDecel = 0.45;//0.5;
const float baseFriction = 0.046875;
const float waterFriction = 0.125;
const float iceFriction = 0.016875;
const float topRunSpeed = 6.0;
const float topWalkSpeed = 4.0;
const float jmp = -9.0;//-6
const float topWalkingSpeed = 3.0;
const float topXSpeed = 6.0;
const float topYSpeed = 2.0;//speed down 6 for kirby(at 30f/s), 16 for Sonic
//lul ok mte
const float gravity = 0.367;//0.21875/3;
float jumpAccel = jmp;
int jumpFrames = 180;
int jumpCounter = 0;
//const float gravity = 0.105;
Vec nextPos;//Top Left Edge
Vec prevPos;//Top Left edge
int time = 0;
int boundingBoxSizeX = 16;
int boundingBoxSizeY = 16;
};
#endif