Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function love.load()
- hamster = love.graphics.newImage("hamster.png")
- x = 350
- y = 350
- rot = 0
- speed = 900
- end
- function love.update(dt)
- if love.keyboard.isDown("right") then
- x = x + (speed * dt)
- elseif love.keyboard.isDown("left") then
- x = x - (speed * dt)
- end
- if love.keyboard.isDown("down") then
- y = y + (speed * dt)
- elseif love.keyboard.isDown("up") then
- y = y - (speed * dt)
- end
- if love.keyboard.isDown("e") then
- rot = rot + (speed * dt) / 3.14 /100
- end
- if x > 900 - hamster:getWidth() then x = 900 - hamster:getWidth()
- end
- if x < 170 - hamster:getWidth() then x = 170 - hamster:getWidth()
- end
- if y > 680 - hamster:getWidth() then y = 680 - hamster:getWidth()
- end
- if y < 220 - hamster:getWidth() then y = 220 - hamster:getWidth()
- end
- end
- function love.draw()
- love.graphics.draw(hamster, x, y, rot)
- end
- love.graphics.setBackgroundColor(255, 255, 255)
- love.graphics.getWidth()
- love.graphics.getHeight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement