Skip to content
Browse files

ooooo keybindings

  • Loading branch information...
1 parent 0f478a9 commit 7d0f47337ef7eeaf043b4bdef9c324f9d3bcad87 @dsosby committed Apr 4, 2012
Showing with 9 additions and 11 deletions.
  1. +9 −11 main.lua
View
20 main.lua
@@ -1,23 +1,21 @@
function love.load()
x = 100
y = 100
+
+ keybindings = {
+ left = function() x = x - 10 end,
+ right = function() x = x + 10 end,
+ up = function() y = y - 10 end,
+ down = function() y = y + 10 end
+ }
end
function love.draw()
love.graphics.print("Hello Love!", x, y)
end
function love.update(dt)
- if love.keyboard.isDown("left") then
- x = x - 10
- end
- if love.keyboard.isDown("right") then
- x = x + 10
- end
- if love.keyboard.isDown("up") then
- y = y - 10
- end
- if love.keyboard.isDown("down") then
- y = y + 10
+ for key,fn in pairs(keybindings) do
+ if love.keyboard.isDown(key) then fn() end
end
end

0 comments on commit 7d0f473

Please sign in to comment.
Something went wrong with that request. Please try again.