Created
August 17, 2013 17:45
-
-
Save PragTob/6257962 to your computer and use it in GitHub Desktop.
I just quickly wrote a bouncing ball implementation in shoes4 as seen in the ruby-processing talk
This file contains hidden or 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
| Shoes.app title: 'bouncing ball' do | |
| strokewidth 5 | |
| circle = oval 40, 40, 100 | |
| SPEED = 10 | |
| xspeed = SPEED | |
| yspeed = SPEED | |
| animate 30 do | |
| xspeed *= -1 if circle.right >= width || circle.left <= 0 | |
| yspeed *= -1 if circle.top <= 0 || circle.bottom >= height | |
| circle.move circle.left + xspeed, circle.top + yspeed | |
| end | |
| click do | |
| circle.fill = rgb rand(255), rand(255), rand(255) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment