Computer Science Canada

Particle thingy I tried :P

Author:  copthesaint [ Sat Jan 29, 2011 11:22 pm ]
Post subject:  Particle thingy I tried :P

Ok, so I spent the last 2-3 hours working on this out of my boredom and its not finished, however at the moment I am wondering why my particle thingy isn't looping, why it isn't recreating it's self. Even apon reseting them they dont create new particles.. Sad Anyways if anyone would like to look throught the code, more specificaly the imageColor and DrawParticle methods, that would be cool Razz. I have attached the two files below enclosed in a zip, the image what is used for example purposes, but can be changed for any image of any size.

Author:  TerranceN [ Sun Jan 30, 2011 11:31 am ]
Post subject:  Re: Particle thingy I tried :P

First of all, your class does not represent a single particle, as its name suggests, instead it represents a particle spawner. Second, why does your Particle class inherit from backImage? I'm going to guess you mean import. Also, why didn't you encapsulate all those parallel arrays into a record or class? It would have made your code much more readable.

Next time you ask for help, unless your code is self documenting or simple, please include a comment or two explaining what everything is supposed to do, cause it took me awhile to understand what everything was supposed to do.

Now onto the problem. From what I have read of your code, indexSize is the maximum index that contains particles whose particleDraw value is true, so this loop will never find a particle whose particleDraw value is false.
Turing:

for i : 0 .. indexSize
    if particleDraw (i) = false then
        dynIndex := i
        exit
    end if
end for


Instead change the upper bound to upper(particleDraw), so that it will check all particles.


: