Say I have this class called Spaceship
Now off coarse I have to give command to this Spaceship like go here and go there
I have fully implemented steering behavior like seek, flee, avoid,
but I am having a hard time deciding whether I should put something like
the command system inside the class or outside the class
something like
var ship = new Spaceship( param );
io.on('connection', function( socket ){
socket.on('command', function( cmd ){
if( cmd.instruction == 'move' )
ship.moveTo( cmd.x, cmd.y );
}
});
There are some command that need interaction with other classes not just one class something like shooting missile
when shooting missile it have to know the location of the enemy which need a pointer to the enemy
and also it need to spawn missile class and push them to missiles array which is concealed deep inside another class
so should I just make this class something like Commander
to tell each unit what to do
There will be one Commander class per player
What do you think ?
is there a major flaw both of these ?