Skip to content

Instantly share code, notes, and snippets.

@InternetExplorer
Created April 3, 2012 14:50
Show Gist options
  • Select an option

  • Save InternetExplorer/2292622 to your computer and use it in GitHub Desktop.

Select an option

Save InternetExplorer/2292622 to your computer and use it in GitHub Desktop.
Marshmallow People Game - Otter Destruction Example Code
// Otter destruction
// An example of how Underscore.js and Impact make it easy to destroy
// all the enemies on-screen with a giant otter
destroyEverthing: function() {
// Grab all active enemies
_.each(ig.game.getAllEnemies(), function(e){
// Check if an enemy is on screen
if(e.isOnScreen) {
// Split points between all players
var points = e.killScore/ig.game.players.length;
// Loop through all players in the game
_.each(ig.game.players, function(p){
// Boredom points awarded within enemy kill function to attackers
e.addAttackers(p);
// Award points
p.score += points;
});
// Destroy Enemy
e.receiveDamage(e.health, this);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment