• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Particle System, always equals 0 ?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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[0] (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[0][0] will have the first particle's X position, not the particle count.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic