summaryrefslogtreecommitdiff
path: root/src/main/scala/graphyx/tests/Chain.scala
blob: 27511ca8a4b7f66d773d37a9b671b1c06c060a40 (plain) (blame)
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
/*
 * Graphyx
 * copyright (c) 2009 Jakob Odersky
 * made available under the MIT License
*/

package graphyx.tests

import sims.dynamics._
import sims.dynamics.joints._
import sims.prefabs._
import sims.geometry._

object Chain extends Test{
  override val title = "Chain"
  val world = new World
  def init = {
    val nodes = for (i <- (0 until 20).toList) yield (new Circle(0.02, 1) {pos = Vector2D(i * 0.2, 1)}).asBody
    nodes(0).fixed = true
    nodes(19).fixed = true
    val connectors = for (i <- (0 until nodes.length - 1).toList) yield new DistanceJoint(nodes(i), nodes(i + 1))
    for (n <- nodes) world += n
    for (c <- connectors) world += c
    world += (new Circle(1,0.001) {pos = Vector2D(2,2)}).asBody
  }
}