Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Particle System  (Read 5073 times)
0 Members and 1 Guest are viewing this topic.
Offline Joshua Waring
« Posted 2012-10-01 11:29:27 »

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.


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

The world is big, so learn it in small bytes.
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #1 - Posted 2012-10-01 19:03:26 »

Looks good, but maybe a fps / entity counter can be handy.
Offline Joshua Waring
« Reply #2 - Posted 2012-10-02 01:40:27 »

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

The world is big, so learn it in small bytes.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 138
Projects: 4
Exp: 3 years



« Reply #3 - Posted 2012-10-02 05:15:52 »

Post screenshot please!
(your current image isn't showing up)
Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2012-10-03 22:45:21 »

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

Offline Joshua Waring
« Reply #5 - Posted 2012-10-04 10:21:01 »

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

The world is big, so learn it in small bytes.
Offline StumpyStrust
« Reply #6 - Posted 2012-10-05 04:01:31 »

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. 

Offline Joshua Waring
« Reply #7 - Posted 2012-10-05 08:47:55 »

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....

The world is big, so learn it in small bytes.
Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #8 - Posted 2012-10-05 12:20:45 »

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

Online theagentd

« JGO Bitwise Duke »


Medals: 361
Projects: 2
Exp: 8 years



« Reply #9 - Posted 2012-10-05 12:45:52 »

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

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Joshua Waring
« Reply #10 - Posted 2012-10-05 13:46:16 »

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

The world is big, so learn it in small bytes.
Online theagentd

« JGO Bitwise Duke »


Medals: 361
Projects: 2
Exp: 8 years



« Reply #11 - Posted 2012-10-05 15:06:59 »

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.

Myomyomyo.
Offline matheus23

JGO Kernel


Medals: 113
Projects: 3


You think about my Avatar right now!


« Reply #12 - Posted 2012-10-05 15:23:29 »

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....  Grin Pointing Roll Eyes

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Joshua Waring
« Reply #13 - Posted 2012-10-05 15:56:15 »

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.

The world is big, so learn it in small bytes.
Offline Joshua Waring
« Reply #14 - Posted 2012-10-08 01:24:29 »

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);

The world is big, so learn it in small bytes.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (16 views)
2014-11-26 15:22:04

toopeicgaming1999 (15 views)
2014-11-26 15:20:36

toopeicgaming1999 (7 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (24 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!