Removed implementation classes
Leaves only the framework in the compiled clause. Find the removed files in ../examples/misc/
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package nz.ac.massey.javaecs;
|
||||
|
||||
public class PhysicsSystem extends ECSSystem{
|
||||
ECS gameEngine;
|
||||
public PhysicsSystem(ECS gameEngine){
|
||||
this.gameEngine = gameEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
void init() {}
|
||||
|
||||
@Override
|
||||
void update() {}
|
||||
|
||||
void update(Double dt){
|
||||
for (Integer entity : entities) {
|
||||
Vec2D pos = (Vec2D)gameEngine.getComponentData(entity, Vec2D.class);
|
||||
RidgidBody ridgidBody = (RidgidBody)gameEngine.getComponentData(entity, RidgidBody.class);
|
||||
Gravity gravity = (Gravity)gameEngine.getComponentData(entity, Gravity.class);
|
||||
// Firstly, add the result of the accelerative forces to the ridgidbody
|
||||
ridgidBody.xdot += ridgidBody.xAcc * dt;
|
||||
ridgidBody.ydot += ridgidBody.yAcc * dt;
|
||||
|
||||
// Special case of gravity
|
||||
if (gravity.terminalX < 0 || Math.abs(ridgidBody.xdot) < gravity.terminalX){
|
||||
ridgidBody.xdot += gravity.x * dt;
|
||||
}
|
||||
if (gravity.terminalY < 0 || Math.abs(ridgidBody.ydot) < gravity.terminalY){
|
||||
ridgidBody.ydot += gravity.y * dt;
|
||||
}
|
||||
|
||||
// Finally, move the vec2d by the new velocity
|
||||
pos.x += ridgidBody.xdot * dt;
|
||||
pos.y += ridgidBody.ydot * dt;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user