Skip to content

Commit b0334d6

Browse files
committed
Added scale
1 parent da6d9e9 commit b0334d6

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

api/src/main/java/com/javaphysicsengine/api/PWorld.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
public class PWorld {
2121
// Physic properties about this world
2222
private static final double GRAVITY_ACCELERATION = -9.81;
23+
private static final double SCALE = 100;
2324

2425
// List containing the physical bodies and joints
25-
private ArrayList<PBody> bodies = new ArrayList<PBody>();
26-
private ArrayList<PConstraints> constraints = new ArrayList<PConstraints>();
26+
private ArrayList<PBody> bodies = new ArrayList<>();
27+
private ArrayList<PConstraints> constraints = new ArrayList<>();
2728

2829
/**
2930
* Post-condition: Returns the list of bodies added to the world
@@ -139,8 +140,8 @@ private void translateBodies(double timeEllapsed) {
139140
body.getVelocity().setY(body.getVelocity().getY() + accelerationY * timeEllapsed);
140141

141142
// Getting the amount to translate by (Velocity = displacement / time)
142-
double dx = body.getVelocity().getX() * timeEllapsed;
143-
double dy = body.getVelocity().getY() * timeEllapsed;
143+
double dx = body.getVelocity().getX() * timeEllapsed * SCALE;
144+
double dy = body.getVelocity().getY() * timeEllapsed * SCALE;
144145

145146
// Translate the body
146147
body.translate(new Vector(dx, dy));

api/src/main/java/com/javaphysicsengine/api/body/PBody.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public abstract class PBody {
3030
// The graphic properties of the object
3131
private Color outlineColor = Color.BLACK;
3232
private Color fillColor = Color.BLUE;
33+
private Color normalVectorColor = Color.RED;
3334

3435
public Color getNormalVectorColor() {
3536
return normalVectorColor;
@@ -39,8 +40,6 @@ public void setNormalVectorColor(Color normalVectorColor) {
3940
this.normalVectorColor = normalVectorColor;
4041
}
4142

42-
private Color normalVectorColor = Color.RED;
43-
4443
/**
4544
* Creates a PBody object with a certain name attached
4645
* Pre-condition: "bodyName" must not be null

0 commit comments

Comments
 (0)