Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def move(): Unit = {
- val someSnake = game.players.find(p => p.snake.headColor != headColor)
- if (someSnake.isDefined) {
- val nbr_snake = someSnake.get.snake
- if (isHeadCollision(nbr_snake)) {
- dir match {
- case North | South => dir = East; nbr_snake.dir = West
- case East | West => dir = North; nbr_snake.dir = South
- case _ =>
- }
- }
- if (isTailCollision(nbr_snake)) game.enterGameOverState()
- }
- if (!isOccupyingBlockAt(body.head + dir)) (body.head + dir) +=: body else game.enterGameOverState()
- if (body.size > initTailSize) body -= body.last
- } // väx och krymp enl. regler; action om äter frukt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement