1 decade ago by fugufish
have a question about design:
am making a 2d side scrolling shooter like Biolab.
on EACH enemy entity, I have the following code to track the distance btw. player and enemy.
if I have 50 entities in a level, all positioned at different areas, this means that that's 50 'get' calls on my Player. Is this too much for the machine to handle?
Any alternative to this method?
am making a 2d side scrolling shooter like Biolab.
on EACH enemy entity, I have the following code to track the distance btw. player and enemy.
update:function(){
var player = ig.game.getEntitiesByType( EntityPlayer )[0];
if( player ) {
var ydist=Math.abs(player.pos.y-this.pos.y);
var xdist=Math.abs(player.pos.x-this.pos.x);
// do stuff, like fire upon the player
}
if I have 50 entities in a level, all positioned at different areas, this means that that's 50 'get' calls on my Player. Is this too much for the machine to handle?
Any alternative to this method?
