Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. function love.load()
  2. hamster = love.graphics.newImage("hamster.png")
  3. x = 350
  4. y = 350
  5. rot = 0
  6. speed = 900
  7. end
  8.  
  9. function love.update(dt)
  10. if love.keyboard.isDown("right") then
  11. x = x + (speed * dt)
  12. elseif love.keyboard.isDown("left") then
  13. x = x - (speed * dt)
  14. end
  15.  
  16. if love.keyboard.isDown("down") then
  17. y = y + (speed * dt)
  18. elseif love.keyboard.isDown("up") then
  19. y = y - (speed * dt)
  20. end
  21.  
  22. if love.keyboard.isDown("e") then
  23. rot = rot + (speed * dt) / 3.14 /100
  24. end
  25.  
  26. if x > 900 - hamster:getWidth() then x = 900 - hamster:getWidth()
  27.  
  28. end
  29.  
  30. if x < 170 - hamster:getWidth() then x = 170 - hamster:getWidth()
  31.  
  32. end
  33.  
  34. if y > 680 - hamster:getWidth() then y = 680 - hamster:getWidth()
  35.  
  36. end
  37.  
  38. if y < 220 - hamster:getWidth() then y = 220 - hamster:getWidth()
  39.  
  40. end
  41.  
  42. end
  43.  
  44.  
  45. function love.draw()
  46. love.graphics.draw(hamster, x, y, rot)
  47. end
  48.  
  49. love.graphics.setBackgroundColor(255, 255, 255)
  50.  
  51. love.graphics.getWidth()
  52.  
  53. love.graphics.getHeight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement