# File gtk2/sample/misc/cairo-pong.rb, line 68 def initialize(dx=0.02, dy=0.02) super(0.8, 0.5, 0.04, 0.04) @dx = dx @dy = dy end
# File gtk2/sample/misc/cairo-pong.rb, line 74 def update @x += @dx @y += @dy # ball bouncing if max_y > 1 @y = 1 - (max_y - 1) @dy *= -1 elsif min_y < 0 @y -= min_y @dy *= -1 end if max_x > 1 @x = 1 - (max_x - 1) @dx *= -1 elsif min_x < 0 @x -= min_x @dx *= -1 end end