Last active
April 4, 2016 20:58
-
-
Save luizcarlos1405/c1c979f1269a1e66691f57e4d9106e85 to your computer and use it in GitHub Desktop.
LÖVE 02 EXTRA - Videoaula em: https://youtu.be/1L3D-P8tZ0Q
This file contains hidden or 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
function love.load() | |
Player = {} | |
Player.x = 0 | |
Player.y = 0 | |
Player.r = 20 | |
Player.speed = 300 | |
Player.xvel = Player.speed * math.cos(math.pi / 4) | |
Player.yvel = Player.speed * math.sin(math.pi / 4) | |
end | |
function love.update(dt) | |
if love.keyboard.isDown("w") and love.keyboard.isDown("a") then | |
Player.y = Player.y - Player.yvel * dt | |
Player.x = Player.x - Player.xvel * dt | |
elseif love.keyboard.isDown("a") and love.keyboard.isDown("s") then | |
Player.y = Player.y + Player.yvel * dt | |
Player.x = Player.x - Player.xvel * dt | |
elseif love.keyboard.isDown("s") and love.keyboard.isDown("d") then | |
Player.y = Player.y + Player.yvel * dt | |
Player.x = Player.x + Player.xvel * dt | |
elseif love.keyboard.isDown("d") and love.keyboard.isDown("w") then | |
Player.y = Player.y - Player.yvel * dt | |
Player.x = Player.x + Player.xvel * dt | |
elseif love.keyboard.isDown("w") then | |
Player.y = Player.y - Player.speed * dt | |
elseif love.keyboard.isDown("a") then | |
Player.x = Player.x - Player.speed * dt | |
elseif love.keyboard.isDown("s") then | |
Player.y = Player.y + Player.speed * dt | |
elseif love.keyboard.isDown("d") then | |
Player.x = Player.x + Player.speed * dt | |
end | |
end | |
function love.draw() | |
love.graphics.circle("line", Player.x, Player.y, Player.r) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment