Untitled
unknown
scala
3 years ago
588 B
8
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 BugEditor is loading...