Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by dotnetprodev

I am in the process of designing the classes for my game.

Question: What is the best way to describe a parent class of Projectile and its child classes? A Bullet subclass can be a Projectile. There is also Bombs and maybe Grenades. What are the properties of the super (parent) class and the child classes such as Bullet?

Does anybody have any experience with this?

1 decade ago by alexandre

You may also use 2 classes: Projectile, and ProjectileFactory, the latter spawning and configuring Projectile instances according to a set of properties that it maintains for each known type.

ig.Projectile.TYPE = {
BASIC:0,
BULLET:1,
GRENADE:2,
BOMB:3,
NUKE:4,
SNOT:5,
PEBBLE:6,
NAG:7};

ig.ProjectileFactory = ig.Class.Extend...

makeProjectile: function(x, y, settings)
{
  var pType = settings.type ? settings.type : ig.Projectile.BASIC;
  switch (pType)
  ...
}

1 decade ago by Jerczu

Heh have a look at JavaScript development patterns. I personally create universal parent class and then change its properties in different instances.
Page 1 of 1
« first « previous next › last »