This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm trying to create my first particle system, when you click it creates a particle with addParticle at the position of the mouse click (LWJGL) and if the location of the particle (X,Y) fallse out of the range the index will be added to a stack which marks unused index's in the particles array so I can save space and reuse
but the problem is the cull, or maybe it's the add Particle, because the position is always being set to 0.0, EVEN THOUGH I've used a system.out.println to see the values given by Mouse.getX and it is working perfectly. That's the mind((()
Can someone please help.
It looks to me like you are always filling in the information for the same particle: length is set to the value of ACT_PARTICLES as it stands at the beginning of the method call, and is not changed during the while loop. You do change the value of ACT_PARTICLES during the course of the while loop, but since length is a different variable it is a COPY when you first assign length = ACT_PARTICLES, so incrementing ACT_PARTICLES does not change the value of length. It seems to me like the first time the method is called, you assign to particles (which you never test with the cull method). The second time you run the method you would assign all values to particles[n] where n is the number of particles added the first time the method was called. etc...
You also have this comment:
That isn't true. particles will have the first particle's X position, not the particle count.
Afraid I don’t understand the question, nor the code, which is difficult to read with the long lines (I split one in two) and the many commented‑out lines. Please have a look at some conventions about indenting and long lines (though those two conventions differ from each other in some places.
Please explain what you want to happen, and what is actually happen. You are not creating particles, because you don’t appear to have a Particle class. You are simply collecting numbers in an array. What are you using the stack for? Don’t use Stack, but use this.