Here is my progress so far:
Code: Select all
function love.load()
sprites = {}
sprites.player = love.graphics.newImage('sprites/player.png')
sprites.bullet = love.graphics.newImage('sprites/bullet.png');
sprites.zombie = love.graphics.newImage('sprites/zombie.png');
sprites.background = love.graphics.newImage('sprites/background.png');
player = {}
player.x = 600
player.y = 200
player.speed = 3
end
function love.update(dt)
if love.keyboard.isDown("s") then
player.y = player.y + player.speed
end
if love.keyboard.isDown("w") then
player.y = player.y - player.speed
end
if love.keyboard.isDown("s") then
player.y = player.y + player.speed
end
if love.keyboard.isDown("a") then
player.x = player.x - player.speed
end
if love.keyboard.isDown("d") then
player.x = player.x + player.speed
end
end
function love.draw()
love.graphics.draw(sprites.background, 0, 0)
love.graphics.draw(sprites.player, player.x, player.y)
end
* This will help me visually see that he is sitting on the top left of his given area by default
* It will also help me see (later) at what point collisions happen.
Is this possible with love2d?
Thanks!