forked from shaswata56/Taos-Adventure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphysX.hpp
53 lines (47 loc) · 1008 Bytes
/
physX.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
#ifndef PHYSX_HPP_INCLUDED
#define PHYSX_HPP_INCLUDED
#include "levels.hpp"
float friction = -0.4;
float velocityX = 0;
float velocityY = 0;
float accelerationX = 0;
float accelerationY = 0;
float gravity = 1.4;
int pressUpCount = 0;
void updateMovement()
{
if(y < ground){
velocityY += gravity;
}
else if(y > ground){
y = ground;
pressUpCount = 0;
}
if(velocityX > 0 && y >= ground){
velocityX -= 1;
}
else if(velocityX < 0 && y >= ground){
velocityX += 1;
}
switch(level){
case 1:
updateGround1();
break;
case 2:
updateGround2();
break;
case 3:
updateGround3();
break;
case 4:
updateGround4();
break;
default:
break;
}
velocityX += accelerationX*friction;
velocityY += accelerationY*friction;
x += velocityX;
y += velocityY;
}
#endif // PHYSX_HPP_INCLUDED