Open krstffr opened 11 years ago
Hmm, the moveRockets() method probably should go on the Rocket object?
I think we might need a global game class which keeps track of all game world entities, so in each entity's (enemies, rockets etc) kill method we simply call game.removeEntity(this). And when we spawn a new entity we call game.addEntity(this)? Maybe it makes sense to put stuff like update, draw, and kill functions in a base entity class and set this as the prototype? I'm looking into how they dealt with this stuff in impact.js maybe we can get some ideas from there
That sounds smart, to keep all the objects in a game class. Kind of messy to find them otherwise! Good good.
Also placing update, draw, kill etc. in it's own class/mixin makes sense as well.
If an enemy shoots a rocket and then is killed (while the rocket is still alive) the rocket will keep on living.
The bigger question here is probably: the enemy has a kill method. This method should also eliminate any rockets spawned. But these are spawned by the asShooter mixin, so the logic should probably come from the mixin.
Can you (in a clean and nice way) pass down additional logic into an inheriting class method from a mixin? Sort of like "from the mixin put destroyRockets() method in inheriting objects kill() method" in plain english.
This is in a way the same question as #9 I guess?