Why my code doesn't work ?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Gurkani
Prole
Posts: 5
Joined: Sun Apr 27, 2014 3:53 pm

Why my code doesn't work ?

Post by Gurkani »

http://pastebin.com/vuDRxJXB
(I'm begginer on LÖVE)
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Why my code doesn't work ?

Post by veethree »

Please try to be more specific when asking for help, Tell us if you're getting an error, if so what error etc.

There's 2 problems in there, First, I got an error with your - sign, 2nd, You didn't end the love.update function.

Here's the working code:

Code: Select all

function love.load()
p = {}
p.x = 300
p.y = 400
love.graphics.setBackgroundColor(182, 100, 0)
love.graphics.setColor(0, 0, 225)
end
function love.draw()
love.graphics.rectangle("fill", p.x, p.y, 100, 100)
end
function love.update(dt)
if love.keyboard.isDown('d') then
p.x = p.x + 1 * dt
elseif love.keyboard.isDown('a') then
p.x = p.x - 1 * dt
end
end
Also this:

Code: Select all

p.x = p.x - 1 * dt
will make the player move incredibly slow, You may want to change that 1 to something higher.
Gurkani
Prole
Posts: 5
Joined: Sun Apr 27, 2014 3:53 pm

Re: Why my code doesn't work ?

Post by Gurkani »

Thanks :)
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests