Skip to content

Commit

Permalink
Display randomized white rectangles around the map
Browse files Browse the repository at this point in the history
  • Loading branch information
practicingruby committed Sep 25, 2011
1 parent 8965b11 commit 7da2104
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
@rect = Ray::Polygon.rectangle([-10, -10, 20, 20], Ray::Color.red)
@rect.pos = [200,200]

max_x = window.size.width - 20
max_y = window.size.height - 20

@goodies = 20.times.map do
x = rand(max_x) + 10
y = rand(max_y) + 10

g = Ray::Polygon.rectangle([0,0,10,10])
g.pos = [x,y]

g
end

always do
@rect.pos += [-2, 0] if holding?(:left)
@rect.pos += [2, 0] if holding?(:right)
Expand All @@ -15,6 +28,7 @@
end

render do |win|
@goodies.each { |g| win.draw(g) }
win.draw @rect
end
end
Expand Down

0 comments on commit 7da2104

Please sign in to comment.