Last active
April 14, 2016 13:50
-
-
Save darmie/3d33fcfaedbc2cec764b49f65eed6b60 to your computer and use it in GitHub Desktop.
Moving Box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local player = {} --the player object | |
function love.load() | |
player.x = 300 | |
player.y = 400 | |
end | |
function love.update(dt) | |
if love.keyboard.isDown('d') then | |
player.x = player.x + 1 * dt | |
elseif love.keyboard.isDown('a') then | |
player.x = player.x - 1 * dt | |
end | |
if love.keyboard.isDown('w') then | |
player.y = player.y - 1 * dt | |
elseif love.keyboard.isDown('s') then | |
player.y = player.y + 1 * dt | |
end | |
end | |
function love.draw() | |
love.graphics.setColor(0, 0, 225) | |
love.graphics.rectangle("fill", player.x, player.y, 100, 100) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment