Permalink
Browse files

Get rectangle to move left on left key press

  • Loading branch information...
1 parent 0d33290 commit 125f61516f39f024f550b44aff4c3f15a341dd83 @practicingruby practicingruby committed Sep 25, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −3 game.rb
View
11 game.rb
@@ -7,14 +7,19 @@
@rect = Ray::Polygon.rectangle([-10, -10, 20, 20], Ray::Color.red)
@rect.pos = [200,200]
- on :mouse_motion do |pos|
- @rect.pos = pos
+ on :key_press, key(:left) do
+ @moving_left = true
+ end
+
+ on :key_release, key(:left) do
+ @moving_left = false
end
render do |win|
win.draw @rect
+ @rect.pos += [-1,0] if @moving_left
end
end
+
scenes << :square
end
-

0 comments on commit 125f615

Please sign in to comment.