Created
August 1, 2018 12:08
-
-
Save erloncabral/b5a6ca830ffa02ff51234757a2f4b341 to your computer and use it in GitHub Desktop.
love 2d keyboard directions
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 x_input = 0 | |
local y_input = 0 | |
local line_width = 32 | |
function love.update(dt) | |
x_input = (love.keyboard.isDown("right") and 1 or 0) - (love.keyboard.isDown("left") and 1 or 0) | |
y_input = (love.keyboard.isDown("down") and 1 or 0) - (love.keyboard.isDown("up") and 1 or 0) | |
end | |
function love.draw() | |
love.graphics.line(line_width, line_width, (line_width + x_input * line_width), (line_width + y_input * line_width)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment