Page 1 of 1

Input not working, Help!

Posted: Wed Jul 16, 2014 5:56 pm
by norman106
Hi,

Im new to love (and lua) so I started off with something small like moving an image around but it seems like my keyboard input does not work.

I've checked out the wiki and other online tutorials and It looks like I'm doing everything right.

Can someone check out my love file and see where I'm going wrong?

any help would be appreciated! thank you!

Re: Input not working, Help!

Posted: Wed Jul 16, 2014 7:26 pm
by veethree
You're not technically doing anything wrong. It should work. The problem may be that the image is moving, But incredibly slow.

The one thing you are doing wrong is not using dt. There's a post on the love2d blogs that goes into what dt is, and why it's important.

But basically what you have to do is something like this:

Code: Select all

function love.update(dt)
	if love.keyboard.isDown("a") then
		x = x - 80 * dt
	end
	if love.keyboard.isDown("d") then
		x = x + 80 * dt
	end
	if love.keyboard.isDown("w") then
		y = y - 80 * dt
	end
	if love.keyboard.isDown("s") then
		y = y + 80 * dt
	end
end

Re: Input not working, Help!

Posted: Wed Jul 16, 2014 7:38 pm
by norman106
I'll check it out. Thanks! :awesome: