Code Sketch


shravani tingare 8th-B
By: tejaswi
Category: Programming

cleari()

val pic = Picture.rectangle(80, 80)
draw(pic)
pic.setPenColor(Color(153,0,0))
pic.setFillColor(black)

val speed = 100
animate {
    val dt = frameDeltaTime
    if (isKeyPressed(Kc.VK_RIGHT)) {
        pic.translate(speed * dt, 5)
    }
    if (isKeyPressed(Kc.VK_LEFT)) {
        pic.translate(-speed * dt, 5)
    }
    if (isKeyPressed(Kc.VK_UP)) {
        pic.translate(0, speed * dt)
    }
    if (isKeyPressed(Kc.VK_DOWN)) {
        pic.translate(0, -speed * dt)
    }
}
activateCanvas()