Problems/Questions creating a flare system

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
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

Problems/Questions creating a flare system

Post by Petunien »

Hi everyone,

I'm trying to create a flare system like one that a modern jet have.

It would work: User presses "X" -> Flares enabled (shot from the player-position at some points (math.random)) -> Flares for a specific timespan locked
-> After that span flares are available again

A flare is at the moment a filled circle with a radius of 4.

I tried it on many ways, but I got problems with the unique targeted point of a unique flare (unique positions of the flares, so a "rocket-pointing" system is possible).
I don't know how to handle the table with the coordinates where the flares are going to and how to go it one for one at different points, and not
all in one time.

I'm helpless, how would that be solved?

It would be very nice if someone explains a solution for that.

And sorry for my english, I hope it is understandable. :)
"Docendo discimus" - Lucius Annaeus Seneca
User avatar
jimflim
Prole
Posts: 4
Joined: Tue Apr 03, 2012 3:01 pm

Re: Problems/Questions creating a flare system

Post by jimflim »

Hi,
I'd suggest you create a flare object which is created on every "X" pressed with
flare.x and flare.y as position.
Then, on every update you just have to for-loop every flare drawing closer to their target until they hit and the remove the flare...
Hope I got your problem right..
Cheers,
jimflim
rvj
Prole
Posts: 15
Joined: Fri Feb 10, 2012 5:55 pm

Re: Problems/Questions creating a flare system

Post by rvj »

I've wanted to make a system for that for a while. I'm not certain I understand your specific question but here are my thoughts:

I'd have a table for each flare that was released:
flare.x
flare.y
flare.heading
flare.timer --just holds the time at which the flare was fired off

a function to release the flares:
--create a new flare table, set flare.heading to point behind or off to the side (and slightly random, not STRAIGHT back...), set x and y to the plane's x and y, set the timer to the current time (love.timer.getTime())
in this function that creates the flare you could decide whether it fired one or two at a time (big planes have two or more flare launchers, fighters generally use one I think).


in update(dt):
for each flare in the table, move it in the direction of heading. how fast should depend on the time the flare has been alive:
love.timer.getTime() - flare.timer
When flares are released they appear to go quickly, then slow down (optional)
I would also use the timer to determine the brightness of the flare, letting it fade after a while.

If I missed the point of the question or can help in some other way let me know.. like I said I've wanted to make a flare system for a while (my desktop background image is currently a C130 releasing hundreds of flares behind it.. it's inspiring)
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

Re: Problems/Questions creating a flare system

Post by Petunien »

Hi,
thank you very much for the approaches and possible solutions, I'm going to try it. :)
Karma is coming.

@rvj
Did you ever finish it?
One of the pictures that gave me the idea... http://www.popularmilitary.com/military ... y1110j.jpg
As you said, very impressive. :)
"Docendo discimus" - Lucius Annaeus Seneca
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot], Google [Bot] and 9 guests