Untitled
unknown
scala
3 years ago
527 B
3
Indexable
class Obstacle(val radius: Int, initialPos: Pos):
private var currentPos = initialPos
def pos = this.currentPos
def approach() =
this.currentPos =
if this.isActive then
this.currentPos.addX(-ObstacleSpeed)
else
Pos(1250, 200)
def touches(bug: Bug) =
(this.radius + bug.radius) > this.currentPos.distance(bug.pos)
def isActive = this.currentPos.x >= -this.radius
override def toString = "center at " + this.pos + ", radius " + this.radius
end Obstacle
Editor is loading...