-
Notifications
You must be signed in to change notification settings - Fork 0
/
Physics_Engine.pde
50 lines (36 loc) · 952 Bytes
/
Physics_Engine.pde
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
//Globals
Body ball;
Static_Body floor;
float MASS_MULT = 1.2f;
//Forces
static PVector gravity = new PVector(0,90f);
static PVector normal = gravity.copy().mult(-1f);
PVector wind = new PVector(5f,-0.0f);
static float pixelFactor;
void calPixelToCm()
{
pixelFactor = height/23;
}
void setup() {
//Initial Functions
calPixelToCm();
//Changing some modes
ellipseMode(RADIUS);
//Setting the screen
size(800, 800);
//Initializing Bodies
ball = new Body("Circle",new PVector(255,0,0),new PVector(100f,300f) , 50f);
floor = new Static_Body("Rect", new PVector(0,float(height - 100)),new PVector(float(width),30));
}
void draw() {
int m = millis();
background(0);
floor.display();
Physics.applyForce(gravity,ball);
//Physics.applyForce(wind,ball);
if(Physics.checkCollisionStatic(ball,floor)){
}
ball.display();
ball.move();
//println(Physics.calVel(ball.location,m) + " cm/seg");
}