Creating moving objects

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
A_Bloke_101
Prole
Posts: 2
Joined: Mon Jan 18, 2010 1:21 am

Creating moving objects

Post 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).
User avatar
napco
Party member
Posts: 129
Joined: Fri Jun 12, 2009 9:28 pm
Location: Ital... ehm...

Re: Creating moving objects

Post 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.
A_Bloke_101
Prole
Posts: 2
Joined: Mon Jan 18, 2010 1:21 am

Re: Creating moving objects

Post by A_Bloke_101 »

Thank you very much, but how do I create the object?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Creating moving objects

Post 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. ;)
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests