Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Pyry

By: a guest on Feb 21st, 2009  |  syntax: Lua  |  size: 0.53 KB  |  views: 110  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -- Example: Moving stuff with the keyboard
  2.  
  3. x, y = 400, 300
  4.  
  5. function load()
  6.     image = love.graphics.newImage("images/love-ball.png")
  7. end
  8.  
  9. function update(dt)
  10.     if love.keyboard.isDown(love.key_left) then
  11.         x = x - 100 * dt
  12.     end
  13.     if love.keyboard.isDown(love.key_right) then
  14.         x = x + 100 * dt
  15.     end
  16.     if love.keyboard.isDown(love.key_up) then
  17.         y = y - 100 * dt
  18.     end
  19.     if love.keyboard.isDown(love.key_down) then
  20.         y = y + 100 * dt
  21.     end
  22. end
  23.  
  24. function draw()
  25.     love.graphics.draw(image, x, y)
  26. end