Skip to content

Instantly share code, notes, and snippets.

@joannecheng
Created August 27, 2013 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joannecheng/6348554 to your computer and use it in GitHub Desktop.
Save joannecheng/6348554 to your computer and use it in GitHub Desktop.
eurucamp example
Bouncing Ball
class BouncingBall < Processing::App
def setup
size 650, 800
smooth
stroke_weight 5
@radius = 80
@xpos = @radius + 5
@ypos = @radius + 5
ellipse @xpos, @ypos, @radius*2, @radius*2
@xpos_change = 10
@ypos_change = 10
end
··
def draw
background 245
@xpos += @xpos_change
@ypos += @ypos_change
ellipse @xpos, @ypos, @radius*2, @radius*2
if @xpos > width - @radius || @xpos < @radius
@xpos_change *= -1
end
if @ypos > height - @radius || @ypos < @radius
@ypos_change *= -1
end
end
def mouse_pressed
fill random(255), random(255), random(255)
end
end
BouncingBall.new :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment