Created
April 3, 2012 14:50
-
-
Save InternetExplorer/2292622 to your computer and use it in GitHub Desktop.
Marshmallow People Game - Otter Destruction Example Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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