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
Player movement
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Player movement
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.
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.
I don't get this one. Restate, please.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
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.Incrypt wrote:My player moves only right and down and Im not very sure how to make him go up and left.
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
"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)Roland_Yonaba wrote:I don't get this one. Restate, please.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
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Player movement
So just follow this guide to unhide file extensions, then change the "zip" part to "love".
Re: Player movement
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.
Who is online
Users browsing this forum: No registered users and 9 guests