Last active
June 29, 2022 14:02
-
-
Save litan/dd15f63a461cc8ce28a0c1cea5e6d203 to your computer and use it in GitHub Desktop.
A simple game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a simple game - you need to keep the rectangle within the canvas | |
// the rectangle moves and grows in size; its speed goes up as its size increases | |
// you can rotate it by pressing the 'P' key; you can make it smaller by clicking on it | |
cleari() | |
drawStage(black) | |
val rect = fillColor(lightGray) * penColor(lightGray) -> PicShape.rect(40, 60) | |
draw(rect) | |
animate { | |
rect.translate(1, 0) | |
rect.scale(1.001) | |
if (isKeyPressed(Kc.VK_P)) { | |
rect.rotate(1) | |
} | |
if (rect.collidesWith(stageBorder)) { | |
rect.setFillColor(red) | |
stopAnimation() | |
} | |
} | |
rect.onMouseClick { (x, y) => | |
rect.scale(0.9) | |
} | |
activateCanvas() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HI