
-----------------------------------
montesser
Fri Nov 12, 2010 11:07 am

Running and stopping a particle script, without ending the whole program
-----------------------------------
What is it you are trying to achieve?
To have my program run my snow particle / space scene, with a designated amount of time and then allow the rest of the program to continue,


What is the problem you are having?
I can make the particles start, but cannot stop them.


Describe what you have tried to solve this problem
 i have tried delays, exit whens, and even exit when count.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




View.Set ("offscreenonly")
colorback (black)
const MaxParticles := 500
const startfirex := 100
const startfirey := 100
const smokelength := 300

type Particle_Type : %declare type
record
x, y, speed : real
end record

var Particles : array 1 .. MaxParticles of Particle_Type %declare array of type that you've made


for i : 1 .. MaxParticles % give particles their initial x,y value
Particles (i).x := Rand.Int (0, maxx) %randmize the x position
Particles (i).y := Rand.Int (0, maxy) %randmize the y position
Particles (i).speed := Rand.Int (3, 5) %randmize the y position


end for


loop %main animation loop
cls %clear the screen

for i : 1 .. MaxParticles %inside this loop we go through all the particles 1 by 1
Particles (i).y -= Particles (i).speed %move down the drop of rain

if Particles (i).y .<
Re-read the question in the post instead of the topic title. Totally misinterpreted the question.

As much as I do think the above is copy pasta, I disagree with the counting idea. Formally checking with the Time.Sec() would be a better alternative since it allows it to be a standard wait across all computers.

You'd start with checking the time as you go into the particle engine, then every rendering of the engine, check if it's been x time since the start, and exit the loop.

Eg:


var start := Time.Sec
loop
    exit when Time.Sec >= start + 5
end loop

