Page 1 of 1
Player movement
Posted: Thu Oct 04, 2012 8:16 pm
by Incrypt
My player moves only right and down and Im not very sure how to make him go up and left.
Also I use a windows 7 and not sure how to change the zip but I'll just give you the main.lua coding
function love.load()
love.graphics.setBackgroundColor(0,0,0)
medium = love.graphics.newFont(45)
picture = love.graphics.newImage("test.jpg")
testx = 300
testy = 300
end
function love.update()
if love.keyboard.isDown("right") then
testx = testx + 1
end
if love.keyboard.isDown("down") then
testy = testy + 1
end
end
function love.draw()
love.graphics.draw(picture,testx, testy)
end
Re: Player movement
Posted: Thu Oct 04, 2012 9:27 pm
by Roland_Yonaba
Hi, Incrypt.
Welcome on the Love forums, where everyone makes löve everyday!
First of all, please consider wrapping your snippets of code with code tags. It makes it easier to read.
Incrypt wrote:
Also I use a windows 7 and not sure how to change the zip but I'll just give you the main.lua coding
I don't get this one. Restate, please.
Incrypt wrote:My player moves only right and down and Im not very sure how to make him go up and left.
Fair enough, just make use of "left" and "up" keys, and act on coordinates in the opposite of what you already did for "right" and "down" moves.
Code: Select all
-- same as before
function love.update()
if love.keyboard.isDown("right") then
testx = testx + 1
end
if love.keyboard.isDown("left") then
testx = testx - 1
end
if love.keyboard.isDown("down") then
testy = testy + 1
end
if love.keyboard.isDown("up") then
testy = testy - 1
end
end
-- same as before
Re: Player movement
Posted: Thu Oct 04, 2012 9:30 pm
by Nixola
Roland_Yonaba wrote:Incrypt wrote:
Also I use a windows 7 and not sure how to change the zip but I'll just give you the main.lua coding
I don't get this one. Restate, please.
"Also, I'm using Windows 7 and I'm not sure on how to change the .zip extension to .love, so I'll just give you main.lua content" (I think)
Re: Player movement
Posted: Thu Oct 04, 2012 9:35 pm
by Roland_Yonaba
So just
follow this guide to unhide file extensions, then change the "zip" part to "love".
Re: Player movement
Posted: Thu Oct 04, 2012 10:14 pm
by Incrypt
Roland_Yonaba wrote:Hi, Incrypt.
Welcome on the Love forums, where everyone makes löve everyday!
First of all, please consider wrapping your snippets of code with code tags. It makes it easier to read.
Sorry,But thanks anyway I never guessed the + and - change it.