javascript game how should I reduce the coupling of an entity from the main window?
<p>I have an entity in a game which has an update method, it needs to target the closest zombie, currently the list of zombies is just a global object which I access but this seems wrong, I could pass the list into the update method but I'm not sure if this is the best approach?</p>

<p>here is a simplified version of my update method:</p>

<pre><code>this.update = function () {
                var targetedZombie = null;
                //TODO: should not be using the zombies object - tight coupling should be removed
                var alivezombies = [];
                for (var zombie in zombies) {
                    if (zombies[zombie].Alive) {
                        alivezombies.push(zombies[zombie]);
                    }
                }

                targetedZombie = this.GetClosestEntity(alivezombies);
                if (targetedZombie) {
                    Fire(this, targetedZombie);
                }
});
</code></pre>
