Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/samples/simple-bounce.rb
blob: 88c8ac0f03749225e4869b178dfb387deddd08ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
xspeed, yspeed = 8.4, 6.6
xdir, ydir = 1, 1

Shoes.app do
  background "#DFA"
  border black, :strokewidth => 6

  nostroke
  @icon = image "#{DIR}/static/shoes-icon.png", :left => 100, :top => 100 do
    alert "You're soooo quick."
  end

  x, y = self.width / 2, self.height / 2
  size = @icon.size
  animate(30) do
    x += xspeed * xdir
    y += yspeed * ydir
    
    xdir *= -1 if x > self.width - size[0] or x < 0
    ydir *= -1 if y > self.height - size[1] or y < 0

    @icon.move x.to_i, y.to_i
  end
end