Code Sketch


Bouncing Ball
By: Nitin Mishra
Category: Programming
cleari()
drawStage(black)
val clr = cm.radialGradient(
    0, 0, blue,
    70, magenta, false
)
val pic2 = Picture.circle(70)
.withFillColor(clr)
.withPenColor(clr)


draw(pic2)

var vel = Vector2D(-3, 5)
animate {
    pic2.translate(vel)
    if (pic2.collidesWith(stageBorder)) {
        vel = bouncePicOffStage(pic2, vel)
    }
}