Page 1 of 1

Creating moving objects

Posted: Mon Jan 18, 2010 1:30 am
by A_Bloke_101
Hello LOVE community
I just found this awesome game engine and so far I'm loving it (Pun and Mcdonalds quote not intended :P )
I just have one question, I figured I should start off small, so I will begin by making a space invaders clone so far its been really easy,
but I was just confused as to how to make the player shoot in only one direction (upwards) when the space bar is pressed, I'm sure this
is fairly simple for you guys but it was confusing to me all the same, so please help me out and post a reply below :ultrahappy: .
Thank you for your time (and hopefully, your help).

Re: Creating moving objects

Posted: Mon Jan 18, 2010 2:13 am
by napco
You'll need to read the "love.keyboard" section of the guide (it's explained 1000 times better than could i). You have to decide if you want to read keyboard inside your main loop or if you want to register keypresses inside a separate callback. (it's simpler that it could seem).

To move an object up you have simply to decrease the y-coordinate you use to display his sprite.

Re: Creating moving objects

Posted: Mon Jan 18, 2010 5:05 am
by A_Bloke_101
Thank you very much, but how do I create the object?

Re: Creating moving objects

Posted: Mon Jan 18, 2010 3:36 pm
by Robin
A_Bloke_101 wrote:Thank you very much, but how do I create the object?
That depends. You probably don't want to use the built-in physics now. It is awesome, but a little complex. Are you familiar with Lua? If not, I suggest you read a Lua tutorial, and PIL is a good read as well.

You can just use a table, for example:

Code: Select all

player = {x = 0, y = 0, speed = 0, angle = 0}
If you did not understand that code, you really need to read a Lua tutorial. ;)