News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Array help

Started by Andreas, June 25, 2008, 08:03:43 AM

Previous topic - Next topic

Andreas

How do you copy one or more types from one array to another?
I want to do this.


dim pSys as tParticleSystem list
dim bufferSys(1000) as tParticleSystem list

CopyArray pSys.tParticleSystem,bufferSys(BufferIndex).tParticleSystem

How do I do this the right way?
I'm trying to do trails for my Particle system   ;D

andreas
The best thing about making space shooters is that space, is easy to draw.

thaaks

I wouldn't copy arrays to get particle trails.

Normally you would have an emitter (following your rocket, mouse, whatever) that emits a certain amount of particles at it's current position. More complex emitters add velocity, gravity, wind, color, fading behavior or a bitmap to use to the emitted particles.

Each particle has a lifetime and some alpha value for example.

On each game loop you would update all emitters (which might create new particles) and all existing particles increasing lifetime and decreasing alpha value (or whatever else you want to do with the particles like velocity, gravity and so on as mentioned above). If the lifetime is reached, the alpha value below zero or the screen borders are left you delete the particle from the list.
Afterwards you draw all remaining particles in your game loop.

That's it. No additional lists - just one list for all particles and one list for all active emitters.

Hope that helps,
Tommy

Andreas

If I had had this post 2 moths ago, I would now be in the future...

For the trails I just put a spawn delay variable on the particles.. ::)
Not always easy seeing whats right in front of you.

Thanks for the quick replay thou.

andreas

ps. more questions to come.. ;D
The best thing about making space shooters is that space, is easy to draw.

thaaks

Quote from: Andreas on June 25, 2008, 10:19:06 AM
ps. more questions to come.. ;D
Just go ahead  ;)

Of course you can enhance your particle system even more: You could introduce something like a container for several emitters.
So you would move the container with your space ship for example. The container would move all it's emitters. This way you can reuse your coded emitters and get complex effects.
In the above example your container could have one fire emitter and one smoke emitter to get a better visualization.

You'll get the idea, I guess  ;D

Cheers,
Tommy

Andreas

This I must add! and maybe a linking to sprites.

after I'm done with the positingJitter And VelocityJitter.. and the variable alpha channel is still eluding me. :'(



andreas
The best thing about making space shooters is that space, is easy to draw.

Andreas

What test can I run on a float to find out if it is a negative value?

andreas
The best thing about making space shooters is that space, is easy to draw.

kevin

if Value#<0 then Print "negative"

Andreas

ofcourse.. sometimes I just don't see these things..

andres
The best thing about making space shooters is that space, is easy to draw.