Particle engine
The Master

Ok, here's the deal. I need an open-source particle engine that really rocks. I honestly can't be assed to do the programming because I have tried before and the math just never works out. So I wanted to ask if anyone knows of an open-source particle engine, preferably with scriptable particle types. Who ever has written one, and hasn't abandoned it or left it half-finished, will be given full credit for his/her work.

Archon

Maybe this? I don't think that it's really what you want but it may give you leads.

Honestly, particle effects are easy to do...

The Master

Was that written with allegro? or does it use a different base for graphics?

I'm not terribly good at those sorts of things. And anyway, if I can get a particle engine that's customisable and works with allegro, it takes another entry off my long list of headaches with writting a good RPG engine.

Wilson Saunders

I agree with Archon. Particle effects are not that difficult, unless you are modeling something really complex. Perhaps it would help us understand your problem if you described what you wanted to model with these particles.

jamyskis

Look at me - I scream NOOB.

I've just put a rockin' particle system into my game, and it took me about an hour. Trust me and the other guys - it is not difficult. You don't have to worry about loads of maths - it just needs to look cool ;D

Jonatan Hedborg

Aye. Most effects can be achieved using particles, particle emitters and particle "affectors" (attracting, repulsing, dampening etc). Emitters and affectors should be treated as game objects (so they can be moved though physics or by some other logic. Whatever really), while particles are usually best treated as a simple (non-oop) struct with position, velocity, life, type and possibly other things like colors, fade-type etc and functions like "draw", "update" and "addForce".

I handle it all like this; I have an object "particleCollection", which has a list of the particles under it's control, together with the affectors used on them.
For each particle, each frame, it does: modifies the particles through the affectors, updates them (and resets and forces acting on it) and draws them.

Trezker

Damnit guys, now you made me want to make a particle system... >:(

The Master
Quote:

Perhaps it would help us understand your problem if you described what you wanted to model with these particles.

I want to be able to script battle animations. Rather than having hundreds of sprite images in the datafile that describe all said battle animations, I can just load a script defining the animation and render it on the fly. I've had a look at EGG, and it seems to do what I'm after.

Quote:

I handle it all like this; I have an object "particleCollection", which has a list of the particles under it's control, together with the affectors used on them.
For each particle, each frame, it does: modifies the particles through the affectors, updates them (and resets and forces acting on it) and draws them.

Did you make a particle engine?

Jonatan Hedborg

Sort of, yeah. I could probably dig out (and clean up) the sources when i get a bit of free time. It has the basic functionality, but not many particle types or emitters.

The Master

Don't worry about it. EGG is a starting point, and the code isn't too hard to read. I'll stick with that and expand on it. I just wanted the basic functionality taken care of.

Believe me, I've been programming that RPG engine, and there are alot of modules to keep track of, and sometimes when I add a new one, bugs pop up in others. The more corners I can safely cut the better, hence why I was after a particle engine.

Kibiz0r
Quote:

Damnit guys, now you made me want to make a particle system... >:(

Hehe, ditto. I've been considering it for a while, but I'm just not far enough into development to set aside time for it yet, so I'm leaving it as a dessert. :P

Ariesnl

try this :

header:

1#ifndef _PARTICLE
2#define _PARTICLE
3 
4#include "Engine.h"
5 
6using namespace ol;
7 
8void init_particles();
9 
10 
11class bsgParticle:public bsgSprite
12{
13public:
14int m_nWait;
15int m_nCol;
16int m_nKind;
17float m_fLife;
18 
19bsgParticle();
20virtual ~bsgParticle();
21 
22void draw(int a_nCameraX,int a_nCameraY);
23void do_ai(float a_fLagCount);
24};
25 
26#endif

implementation

1#include <allegro.h>
2#include "particle.h"
3#include "AIdef.h"
4 
5Rgba * pc_smoke[255];
6Rgba * pc_engine[255];
7Rgba * pc_engine2[255];
8 
9 
10void init_particles()
11{
12for (int i=0;i<256;i++)
13 {
14 pc_smoke<i>= new Rgba(255,255,255,i);
15 }
16}
17 
18 
19bsgParticle::bsgParticle()
20{
21m_nKind=P_SMOKE;
22m_nCol=255;
23m_fLife=50;
24m_nWait=2;
25m_fSpeed=0;
26m_nType=ID_NONE;
27m_blCanCollide=false;
28}
29 
30 
31bsgParticle::~bsgParticle()
32{
33 
34}
35 
36 
37void bsgParticle::do_ai(float a_fLagCount)
38{
39m_fLife-=a_fLagCount;
40m_nCol=int(m_fLife*4);
41if (m_fLife<=0) m_blDestroyed=true;
42}
43 
44void bsgParticle::draw(int a_nCameraX,int a_nCameraY)
45{
46int nDrawX=int(SCREENCENTER_X+(m_fX-a_nCameraX));
47int nDrawY=int(SCREENCENTER_Y+(m_fY-a_nCameraY));
48 
49// only draw what we see
50 
51if ((nDrawX>=-100)&&(nDrawY<900)&&(nDrawY>=-100)&&(nDrawY<700))
52 {
53 switch (m_nKind)
54 {
55 case P_SMOKE:
56 GfxRend::Point( nDrawX, nDrawY, *pc_smoke[m_nCol]);
57 break;
58 
59 case 2:
60 
61 break;
62 
63 case 3:
64 
65 break;
66 }
67 }
68}

This was grabbed from my game engine..
you could easily adapt it to your game

Thread #592121. Printed from Allegro.cc