Input not working, Help!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
norman106
Prole
Posts: 2
Joined: Wed Jul 16, 2014 5:45 pm

Input not working, Help!

Post 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!
Attachments
test.love
(2.89 KiB) Downloaded 71 times
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Input not working, Help!

Post 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
norman106
Prole
Posts: 2
Joined: Wed Jul 16, 2014 5:45 pm

Re: Input not working, Help!

Post by norman106 »

I'll check it out. Thanks! :awesome:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests