-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.h
More file actions
180 lines (126 loc) · 2.84 KB
/
Copy pathPlayer.h
File metadata and controls
180 lines (126 loc) · 2.84 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#pragma once
#include "Sprite.h"
#include "Input.h"
#include "Collision.h"
#include "Emitter.h"
#include "Shape.h"
#include "GameData.h"
#define GRAVITY 0.002f
#define JUMPTIME 300
#define MAXJUMPVEL 0.35f
#define JUMPVEL 0.006f
#define RUNMULTPLIER 1.14f
struct MeleeWeapon {
XMFLOAT4 meleeCol;
bool active = 0;
XMFLOAT3* parent;
float meleeTime = 500.0f;
float curMeleeCounter = 0.0f;
int facing = 0;
float meleeX = 0.25f;
float meleeY = 0.25f;
float meleeOffsetX = 1.5f;
float meleeOffsetY = 1.5f;
XMFLOAT2 meleeOffset = {0.5f, 0.5f};
void UpdateCollision() {
XMFLOAT2 curCol = { parent->x + (facing * meleeOffset.x), parent->y + (meleeOffset.y) };
meleeCol = {
curCol.x - meleeX,
curCol.y + meleeY,
curCol.x + meleeX,
curCol.y - meleeY
};
}
XMFLOAT4 GetCollision() {
return meleeCol;
}
};
enum STATE_PLAYER {
PSTATE_IDLE, PSTATE_JUMPING, PSTATE_CLIMBING, PSTATE_DUCKING, PSTATE_BLOCKING, PSTATE_ONWALL, PSTATE_MELEE
};
extern Input gInput;
struct PlayerVariables {
bool AgainstWallLeft;
bool AgainstWallRight;
bool AgainstLedgeLeft;
bool AgainstLedgeRight;
bool AgainstGround;
bool EffectedByGravity;
bool CanJump;
bool CanDoubleJump;
bool CanWallJump;
bool CanLedgeGrab;
bool CanMelee;
bool CanRun;
bool CanWallSlide;
bool IsJumping;
bool IsDoubleJumping;
bool IsWallJumping;
bool IsLedgeGrabbing;
bool IsMelee;
bool IsRunning;
bool IsWallSliding;
int xFacing;
int yFacing;
UINT AgainstGroundCounter;
UINT AgainstWallCounter;
UINT JumpTimeCounter;
bool JumpButtonReset;
};
class Player {
public:
Player ();
void Create (UINT tex, UINT vShader, UINT pShader);
void Update (double deltaTime);
void Draw ();
void MoveBy (XMFLOAT3 p);
void MoveTo (XMFLOAT3 p);
XMFLOAT3 pos;
XMFLOAT3 vel;
void SetCollision(XMFLOAT4 c);
XMFLOAT4 GetCollision();
PlayerVariables pv;
float dir = 0.0f;
PointShapes ps1;
void GetItem(int msg, int value);
void Damage(int value);
void Heal(int value);
void AddToInv(int value);
void GetObstacle(int msg, int value);
void CollidedWith(int type, int value);
bool IsMeleeFunc();
MeleeWeapon m_meleeWeapon;
GD_BASIC_TYPES m_basicType;
bool contact[PC_COUNT];
private:
void Jump();
void Run();
void LedgeClimb();
void Melee();
void Animate(double deltaTime);
void UpdateCollision();
Sprite sprite;
void CheckContacts();
XMFLOAT3 acc;
XMFLOAT3 prev_pos;
XMFLOAT3 prev_vel;
AS_PLAYER animState = AS_PL_IDLE;
AS_PLAYER prev_animState = AS_PL_IDLE;
int curAnimFrame;
double elapsedTime = 0.0f;
void Animation(double deltaTime);
XMFLOAT4 col;
XMFLOAT4 colOff;
int oGround = 0;
bool jumpReleased = 1;
CircleShape cs1;
//Emitter em01;
bool isDead;
STATE_PLAYER m_curState;
int m_statHP;
double dTime;
bool JumpButton;
bool RunButton;
bool tempVar = 0;
float animationSpeed = 200.0f;
};