diff options
Diffstat (limited to 'src/main/scala/graphyx/tests/Cup.scala')
-rw-r--r-- | src/main/scala/graphyx/tests/Cup.scala | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/scala/graphyx/tests/Cup.scala b/src/main/scala/graphyx/tests/Cup.scala new file mode 100644 index 0000000..ad791f0 --- /dev/null +++ b/src/main/scala/graphyx/tests/Cup.scala @@ -0,0 +1,31 @@ +/* + * Graphyx + * copyright (c) 2009 Jakob Odersky + * made available under the MIT License +*/ + +package graphyx.tests + +import sims.dynamics._ +import sims.geometry._ +object Cup extends Test { + val title = "Cup" + val world = new World + + def init = { + val ground = (new Rectangle(1000, 0.1, 1) {friction = 1}).asBody + ground.fixed = true + world += ground + + val cupShapes = for (i <- 0 to (10 * math.Pi).toInt) yield new Circle(0.1,1) {pos = Vector2D(math.cos(-i / 10.0), math.sin(-i / 10.0)); restitution = 0.0; friction = 1.0} + val cup = new Body(cupShapes: _*) {fixed = true; pos = Vector2D(0, 1)} + world += cup + + val ball1 = (new Circle(0.2, 1) {pos = Vector2D(0, 2)}).asBody + val ball2 = (new Circle(0.2, 1) {pos = Vector2D(-0.4, 2)}).asBody + val ball3 = (new Circle(0.2, 1) {pos = Vector2D(0.4, 2)}).asBody + world += ball1 + world += ball2 + world += ball3 + } +} |