Particle System

I’ve been developing a Particle System as my first project, I do want to create a few games in the future, but I’ve always wanted to create a Particle System. so here it is, Right click to place gravity, 0 to remove gravity completely and left click to spawn particles.

I would like to add in collision, but I haven’t had the time to implement it into the system.

http://imageshack.us/a/img255/701/capturenni.png

Download - https://rapidshare.com/files/3293633547/java.jar

Looks good, but maybe a fps / entity counter can be handy.

If you run it through CMD java -jar “path”
It will give a time in MS per frame and active particles

Post screenshot please!
(your current image isn’t showing up)

This was one of the most awesome thing I’ve ever played with. Source please!!

I will upload the source code once I get back to the computer which it’s located :3 Taking a nice week off to celebrate almost finishing school.

I do have a few things I want to add such as

  • Dynamic Core Allocation. I’m sure it has a different name, but I like the sound of Dynamic Core Allocation
  • Collision, I got bored one day in math so I decided to start thinking about a method for collision, I should implement and test it.
  • A cool looking bar on the side which represents the render time.
  • Resizable

If this is done in java2d resizing is cake.

If in opengl resizing is a little harder but still easy. (i know it is lwjgl)

Would like to know how many particle there are. Should be simple to add. (hint: just set the title to the number of particles) Display.setTitle(blah blah blah)

Cap the fps by calling Display.sync(60) every update.

Like the physics in this but it seems slow. How are you rendering?

Also, want to know how you choose the color for the particles.

PS: is this 2d? or 3D can’t really tell.

This was done is LWJGL and every frame in which the button is clicked down 100 particles will be spawned, It does print to the console the number of active particles and render time per frame in MS, so using CMD will show that, but making it the title name does seem better.

It is only 2D but I should add in that other 1D.

Gravity does slow things down quite a bit, but it is faster then before… I’l upload my first version aswell which which was before I went to ArrayList’s and objects as particles, I used simple Arrays, but that became a problem when removing particles.

The colour is just a random equation involving the speed…

It seems 3D because when each particle changes direction, the color flips, giving the illusion of tiny boxes as particles.

It works pretty well, but there’s one problem: you’re most likely using an ArrayList to store the particles and when they die (fly out of the screen) you simply do a remove(), which causes a huge performance hit if lots of them exit at the same time. Take a look at this thread on how to use two ArrayLists to avoid this at the cost of a very minor performance hit: http://www.java-gaming.org/topics/arraylist-hashtable-or-for-holding-in-game-objects/25388/msg/219160/view.html#msg219160

I actually use a linked list iterator, which makes things nice and quick.

“Nice and quick” as in “slow and stuttering due to the garbage collector”? :persecutioncomplex: I wouldn’t use a LinkedList for anything.

Huhuhuu… never-lisper theeere… ;D :point: ::slight_smile:

My first system was a array which stored the particle positions and I created a nice system for flagging particles to be removed. Got 1 million at about 100ms, though it had some problems, it did make use of the Stride on CPU’s (pre fetch for the next array value once its detected a patten.)

PS I have 4 different versions. V2 and v3 are under developed versions of v4 and v1 is completely different.

Here we go
Source Code for both:
https://docs.google.com/open?id=0B20ZnQ-9hBC3YlVIdnVqTGg5akU

Version1:
https://docs.google.com/open?id=0B20ZnQ-9hBC3aEZyeFB6VkxGQzA

Gravity really slows things down…

The equation for the colour is
GL11.glColor3f((particle.positionY / particle.velocityY), (particle.positionX / particle.velocityX), 1);