Posted: 20th Dec 2011 8:51
Hi All...

I took the Particles Explosion Example that comes with AppGameKit and modified it a bit in a way that seems to have uncovered a bug... but I wanted to be sure.

I'm sending particles up to the right, and shortly after, a strong force reverses their direction.

It repeats.

The bug is that the particle system changes. I believe that each iteration of the explosion should look essentially the same, but you will notice that either the initial force is diminished, or the opposing force is kicking in earlier...

You will see that they go past the right side of the screen, but in just a few cycles don't come even close.

It would be great to have more eyes on this. Let me know what you think:

+ Code Snippet
// explosions with particles

// set a virtual resolution
SetVirtualResolution ( 320, 480 )

// load an image for the particles
LoadImage ( 1, "shrapnel3.png" )

// create particles off screen
CreateParticles ( 1, -100, -100 )

// set fire variable to 1
fire = 1



// main loop
do
    // fire when ready
    if ( fire = 1 )
        // set up particles
        SetParticlesPosition ( 1, 160, 240 )
        ResetParticleCount ( 1 )                    
        SetParticlesFrequency ( 1, 250 )
        SetParticlesLife ( 1, 3.0 )
        SetParticlesSize ( 1, 64 )
        SetParticlesStartZone ( 1, -20, 20, 20, -20 )
        SetParticlesImage ( 1, 1 )
        SetParticlesDirection ( 1, 110, -110 )
        SetParticlesAngle ( 1, 30 )
        SetParticlesVelocityRange ( 1, 1.0, 2.0 )
        SetParticlesMax ( 1, 300 )

        AddParticlesColorKeyFrame ( 1, 0.0, 0, 0, 0, 0 )
        AddParticlesColorKeyFrame ( 1, 0.5, 255, 255, 0, 255 )
        AddParticlesColorKeyFrame ( 1, 2.8, 255, 0, 0, 0 )

        AddParticlesForce ( 1, 0.1, 2.8, -250, 250 )

        // reset fire value
        fire = 0
    endif

    // when the explosion has finished it is safe to fire once more
    if ( GetParticlesMaxReached ( 1 ) )
        fire = 1
    endif

    // update the screen
    sync ( )
loop

Posted: 20th Dec 2011 10:20
What's happening is you are adding a new force each time you start a new set of particles off so the amount of force acting on that emitter is getting larger each time. Put that force before the loop and the effect remains constant.
Posted: 21st Dec 2011 4:24
Ohhhhhhh! It's *ADD*particlesForce... they really mean it!

How does one go about resetting forces I wonder? I kinda wish that the command was SETparticleForce... othewise I can see it getting rather out of control.

Thanks for that insight...
Posted: 21st Dec 2011 7:33
You can reset the forces on a particle emitter then add new forces

EDIT: "ClearParticlesForces( ID )"
Posted: 22nd Dec 2011 7:07
I swear I looked for that

sigh.

Thanks!