forked from shaswata56/Taos-Adventure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphysX.hpp
41 lines (33 loc) · 759 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
#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.9;
int pressUpCount=0;
void updateMovement()
{
if(y < ground){
velocityY += gravity;
}
/// This doesn't work sometime... Gotta fix!
else if(y > ground){
y = ground;
pressUpCount = 0;
}
if(velocityX > 0 && y >= ground){
velocityX -= 1;
}
else if(velocityX < 0 && y >= ground){
velocityX += 1;
}
updateGround();
velocityX += accelerationX*friction;
velocityY += accelerationY*friction;
x += velocityX;
y += velocityY;
}
#endif // PHYSX_HPP_INCLUDED