Advertisement
Guest User

Untitled

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