Skip to content

Instantly share code, notes, and snippets.

@PragTob
Created August 17, 2013 17:45
Show Gist options
  • Select an option

  • Save PragTob/6257962 to your computer and use it in GitHub Desktop.

Select an option

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
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