Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightfold/bab4b79e7125e07b62c2 to your computer and use it in GitHub Desktop.
Save rightfold/bab4b79e7125e07b62c2 to your computer and use it in GitHub Desktop.
val (hittingBullets, missingBullets) =
bullets.partition { bullet => enemies.exists(_.position distanceTo bullet.position < 1) }
bullets = missingBullets
enemies = enemies.map { enemy =>
val healthLoss = hittingBullets.count(_.position distanceTo enemy.position < 1)
enemy.copy(health = enemy.health - healthLoss)
}
enemies = enemies.filter(_.health > 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment