I'm new to LÖVE/LUA and started yesterday trying a few things. Now i have some questions because i couldn't find anything on the forum (may i haven't tried hard enough). I hope this is the right forum place for my thread.
Question 1:
I've a picture and can move it with the up, down, left, right keys. Thats fine, but how can i avoid it running out of the screen (e.g. its 640x480 resolution) when its moving?
Question 2:
How can i change the image depending on which direction the "player" moves? I tried some things but it didn't work (well).
Question 3:
Simple Animations. How do they work? Is there any Tutorial you know or some small code examples?
Question 4:
Simple collision detection. Same as above. Is there any Tutorial you guys know or some small code examples?
Ah yes, heres my little code and thx in advance!
Code: Select all
function love.load()
image = love.graphics.newImage("cake.png")
music = love.audio.newSource("polka.mp3")
love.audio.play(music)
playerX = "190"
playerY = "190"
love.graphics.setBackgroundColor(255,255,255)
end
function love.draw()
love.graphics.draw(image, playerX, playerY)
end
function love.update(dt)
if love.keyboard.isDown("right") then
playerX = playerX + 0.5
end
if love.keyboard.isDown("left") then
playerX = playerX - 0.5
end
if love.keyboard.isDown("up") then
playerY = playerY - 0.5
end
if love.keyboard.isDown("down") then
playerY = playerY + 0.5
end
end