Archived

This topic is now archived and is closed to further replies.

GekkoCube

Bullets, Particles, and their relationship.

Recommended Posts

Ok, this is a little hard to explain for me....so please bear with me. Im thinking about a way using OOP/OOP as much as possible to implement a projectile system (basically shooting a cannon ball from a cannon). I will just explain one way that I have abandoned because I didn''t think it would help me any (and in fact made is more difficult to read/understand than help it). I have a base class called CObject. This object has pure virutal/virtual functions for Render() and Collision(). It also basic info. such as position, velocity, radius....etc. A CProjectile class would inherit from public CObject. So far, does this look good? Second thing, how would a particle system tie in with all this? Should each CProjectile object have a instance of a CParticleSystem in it? Or should a CProjectileSystem be completely separate from CProjectile? ps - basically im trying to figure out the best way. Best = designed for fast speed, minimal memory usage, code readability/comprehensability.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Your question is answered in OpenGL Game Programming by Hawkins and Astle - an EXCELLENT book that I started reading three days ago with no OpenGL experience and I''m already done and working on my own 3D game. Here''s the bit of info that I hope helps..

So far it looks good.. CProjectile class is derived from CObject. You tie in the particle system by creating the new system in the projectile''s animate function.

Here''s how to create a particle system that is a puff of smoke and a smoke trail when you shoot your cannonball..

// in cannonball.h file

class CCannonball : public CProjectile
{
...
public:
CSmokePuff *smokepuff;
CSmokeTrail *smoketrail;
...
}

// in cannonball.cpp file

CCannonball::CCannonball()
{
...
smokepuff = NULL;
smoketrail = NULL;
...
}

CCannonball::Animate()
{
...
if (fire)
{
smokepuff = new CSmokePuff();
smoketrail = new CSmokeTrail();
}
}

CSmokePuff and CSmokeTrail are particle systems derived from CParticleSystem. Each projectile should have its own instance of your particle system..

Hope that helps..
(silencer)

Share this post


Link to post
Share on other sites