• Advertisement

Archived

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

Collection Classes

This topic is 5004 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Baffled student doing games programming here... wonder if anyone could offer any help on creating collection classes for managin explosions for simple 2d games. I have animated a simple explosion and created a class holding an array of explosions. I am struggling identifying where the explosions should occur on screen. Any help or links to tutoirals would be helpful thanks

Share this post


Link to post
Share on other sites
Advertisement
Something like this would probably be ideal:

Assuming you have the following classes:
- CEffectFactory (something to generate new effects), with a linked list (m_Effects) of effects that it has created.
- CEffect (the particle effect itself), and several derived classes that represent different types of effects.
- CParticle (Individual particles)


CEffect* CEffectFactory::CreateEffect(int iEffectType,Vec vPosition, int iFlags)
{
CEffect* pEffect = NULL;

switch(iEffectType)
{
case EFFECT_EXPLOSION:
pEffect = new CExplosion(vPosition, iFlags);
break;
default:
pEffect = new CEffect(vPosition,iFlags);
break;
}

m_EffectList.Add(pEffect);
return pEffect;
}


There are cleaner and more robust ways to do this. The most obvious improvement would be working out a way to eliminate that ugly switch statement, but that's the general concept.

[edited by - Etnu on June 10, 2004 6:59:03 PM]

Share this post


Link to post
Share on other sites

  • Advertisement