Skip to content

Instantly share code, notes, and snippets.

@bulkan
Created April 7, 2009 11:17
Show Gist options
  • Save bulkan/91185 to your computer and use it in GitHub Desktop.
Save bulkan/91185 to your computer and use it in GitHub Desktop.
While in the do while loop the program checks which character the user hits. The first if statement is the guard statement to check the Escape key. If its hit the game state is then set to "y" which ends the do-while loop. The following else if statements check which way to turn the snail. On each do-while loop iteration, it prints the score to the top left corner (lines 120, 121). After the do-while loop the program clears the screen and at x:5, y:5 it then prints the final score and at 12,6 prints a message then the program/game terminates.
The first else-if statement at line 38 checks to see if the snake is right at the top. If it is then it will appear at the bottom. The else..if (line 64) it checks to see if the snake is at the bottom if it is then makes it appear at the top (lines 88 , line 92). else-if at line 88 checks the snake to see if its at the end of the left side of the screen. If it is then it appears on the right. The last else-if statement line: 112 checks to see if the snake is at the end of right side of the screen. If it is then it makes it appear on the left side.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment