-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneSpring.java
More file actions
45 lines (40 loc) · 1.73 KB
/
Copy pathSceneSpring.java
File metadata and controls
45 lines (40 loc) · 1.73 KB
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
public class SceneSpring extends Scene {
public SceneSpring() {
PhysicsObject[] physicsObjects = {
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject(),
new PhysicsObject()
};
for (int i = 0; i < physicsObjects.length; i++) {
Spring spring;
physicsObjects[i].position = physicsObjects[i].position.add(new Vector2(i*1.2,0));
if (i == 0) {
spring = new Spring(new Vector2(-0.5,-7.0/18.0), new Vector2(5,13.5), physicsObjects[i], null);
} else {
spring = new Spring(new Vector2(-0.5,-7.0/18.0), new Vector2(0.5,-7.0/18.0), physicsObjects[i], physicsObjects[i-1]);
physicsObjects[i-1].addForceActor(spring.forceActor);
}
physicsObjects[i].addForceActor(new GravityForceActor());
physicsObjects[i].addForceActor(new DampingForceActor());
physicsObjects[i].addForceActor(spring.forceActor);
gameObjects.add(physicsObjects[i]);
gameObjects.add(spring);
if (i == physicsObjects.length - 1) {
spring = new Spring(new Vector2(0.5,-7.0/18.0), new Vector2(20,13.5), physicsObjects[i], null);
physicsObjects[i].addForceActor(spring.forceActor);
gameObjects.add(spring);
}
}
// super.gameObjects.add(new Marker(new Vector2(1,1)));
}
}