Untitled
unknown
scala
3 years ago
601 B
7
Indexable
package o1.flappy
import o1._
class Bug(private var currentPos: Pos) {
def pos = this.currentPos
private var yVelocity = 0.0
val radius = BugRadius
def flap(strength: Double) = {
this.yVelocity = -strength
}
def fall() = {
if (this.pos.y != 350) {
this.yVelocity = this.yVelocity + 2
}
move(this.yVelocity)
}
def move(amount: Double) = {
this.currentPos = this.currentPos.addY(amount).clampY(0, 350)
}
def isInBounds: Boolean = this.pos.y != 0 && this.pos.y < 350
override def toString = "center at " + this.pos + ", radius " + this.radius
}Editor is loading...