Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def move(): Unit = {
- grow()
- shrink()
- if (body.tail.contains(body.head)) game.enterGameOverState()
- game.entities.foreach{
- ent => if (ent.isOccupyingBlockAt(body.head)) {
- ent match {
- case c:CanTeleport => grow(); ent.reset()
- case _ =>
- }
- }
- }
- if (game.players.length > 1) {
- val other_snake = game.players.find(p => p.snake.headColor != headColor).get.snake
- if (isHeadCollision(other_snake)) {
- dir match {
- case North | South => dir = East; other_snake.dir = West
- case East | West => dir = North; other_snake.dir = South
- case _ =>
- }
- }
- if (isTailCollision(other_snake)) game.enterGameOverState()
- }
- } // väx och krymp enl. regler; action om äter frukt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement