-
-
Save mukeshsolanki/5985e08fcd609d6182c552d9598f8baa to your computer and use it in GitHub Desktop.
This file contains 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
val hasReachedLeftEnd = | |
it.snake.first().first == 0 && it.currentDirection == SnakeDirection.Left | |
val hasReachedTopEnd = | |
it.snake.first().second == 0 && it.currentDirection == SnakeDirection.Up | |
val hasReachedRightEnd = | |
it.snake.first().first == BOARD_SIZE - 1 && it.currentDirection == SnakeDirection.Right | |
val hasReachedBottomEnd = | |
it.snake.first().second == BOARD_SIZE - 1 && it.currentDirection == SnakeDirection.Down | |
if (hasReachedLeftEnd || hasReachedTopEnd || hasReachedRightEnd || hasReachedBottomEnd) { | |
snakeLength = 2 | |
onGameEnded.invoke() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment