Untitled
unknown
scala
2 years ago
588 B
2
Indexable
class Bug(initialPos: Pos): private var currentPos = initialPos def pos = this.currentPos val radius = 15 private var yVelocity = 0.0 override def toString = "center at " + this.pos + ", radius " + this.radius def move(lisaaY: Double) = this.currentPos = this.currentPos.addY(lisaaY).clampY(0, 350) def flap(yChange: Double) = yVelocity = -yChange def fall() = if this.currentPos.y < 350 then yVelocity = yVelocity + 2 move(yVelocity) def isInBounds = this.currentPos.y <= 0 || this.currentPos.y >= 350 end Bug
Editor is loading...