Skip to content

Instantly share code, notes, and snippets.

@walesmd
Created October 8, 2010 16:17
Show Gist options
  • Select an option

  • Save walesmd/617052 to your computer and use it in GitHub Desktop.

Select an option

Save walesmd/617052 to your computer and use it in GitHub Desktop.
directions = {up = {x = 0, y = -1}, down = {x = 0, y = 1}, left = {x = -1, y = 0}, right = {x = 1, y = 0}}
function love.load()
game = {}
game.width = love.graphics.getWidth()
game.height = love.graphics.getHeight()
player = {}
player.x = game.width / 2
player.y = game.height / 2
player.dir = "left"
player.color = {255, 255, 255}
love.graphics.setBackgroundColor(0, 0, 0)
end
function love.update(dt)
end
function love.draw()
love.graphics.setColor(unpack(player.color))
love.graphics.point(player.x, player.y)
end
function love.keypressed(key)
if directions[key] then
player.dir = key
end
if key == "escape" then
love.event.push("q")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment