Game Development - Superpower
Updated at 2013-04-12 10:51
This is a way to implement superpowers and powerups using a well defined structure.
class Superpower
{
public:
virtual ~Superpower() {}
protected:
virtual void activate() = 0;
void move(float x, float y, float z)
{
// Code here...
}
void playSound(SoundId sound, float volume)
{
// Code here...
}
void spawnParticles(ParticleType type, int count)
{
// Code here...
}
// Any other properties what "a superpower event" may cause
};
class SkyLaunch : public Superpower
{
protected:
virtual void activate()
{
// Spring into the air.
playSound(SOUND_SPROING, 1.0f);
spawnParticles(PARTICLE_DUST, 10);
move(0, 0, 20);
}
};