Program helps user de-stress, have fun, and cure boredom by providing small and fun game with a competitive token system.
This program allows users to test their IQ and their reaction time by increasing the length of the snake every time an apple is eating, essentially making the game harder as your progress. The snake is controlled by user input using the arrow keys. The arrow keys allow the user to change the direction in which the snake is moving. When the snake moves over the tile that has an apple, a point is awarded and the snakes length increases. To begin game, the user must spend 10 of their tokens. While playing, the user earns tokens by collecting apples (points). Each apple is 1 token. Tokens are updated live after each game and the net loss/gain is displayed.
The input are the up, down, right, and left arrow keys that are pressed by the user to control and move the snake around. The program detects the key press inputs and reacts the snake accordingly. The output is the movement and change in direction from the snake. When the snake eats an apple, the program recognizes this and automatically outputs a new apple at a random location.
3.B Data Abstraction
The snake body is kept within an empty array and every time the snake runs into a apple the list is added to. The purpose of the array here is to keep / add too the boy of the snake every time food is eaten.
3.C Managing Complexity
This method of using and adding to the empty array manages the complexity of the program. This method allows for the code to stay clean and not too complicated. If this were done any other way it would require multiple lists and longer segments of code. This method allows for less code to be written while still completing the job effectively.
3.B Procedural Abstraction
Here, a End Game function is created (first image). The function states the end game conditions and tells the program what to do when the game ends. In the second image, the function is being called twice. This function ends the game depending on the conditions that are stated within the code. This function is essential to the program because it allows for the reload/ restart options
2.B Algorithm Implementation
4.C Testing
In the images above, on of the conditions being tested is whether the game should end or not. If and for methods are used to determine weather the game should end or not. It checks for collisions against the boundaries, running into itself and if every square is filled; if these conditions are met. The game ends.
The update function displayed above is constantly updating the game. One of the things it does is check to see whether new apples should be spawned on the canvas. The function uses if and return to see whether it is time to place a new food on the canvas. It checks to see if the previous apple has been eaten and if the game hasn't ended, then it spawns a new apple.
CPT
Ahad Biabani Period 3 Mort
Video
CPT VIDEO
Write-Up
4.A Program Purpose and function
Program helps user de-stress, have fun, and cure boredom by providing small and fun game with a competitive token system.
This program allows users to test their IQ and their reaction time by increasing the length of the snake every time an apple is eating, essentially making the game harder as your progress. The snake is controlled by user input using the arrow keys. The arrow keys allow the user to change the direction in which the snake is moving. When the snake moves over the tile that has an apple, a point is awarded and the snakes length increases. To begin game, the user must spend 10 of their tokens. While playing, the user earns tokens by collecting apples (points). Each apple is 1 token. Tokens are updated live after each game and the net loss/gain is displayed.
The input are the up, down, right, and left arrow keys that are pressed by the user to control and move the snake around. The program detects the key press inputs and reacts the snake accordingly. The output is the movement and change in direction from the snake. When the snake eats an apple, the program recognizes this and automatically outputs a new apple at a random location.
3.B Data Abstraction
The snake body is kept within an empty array and every time the snake runs into a apple the list is added to. The purpose of the array here is to keep / add too the boy of the snake every time food is eaten.
3.C Managing Complexity
This method of using and adding to the empty array manages the complexity of the program. This method allows for the code to stay clean and not too complicated. If this were done any other way it would require multiple lists and longer segments of code. This method allows for less code to be written while still completing the job effectively.
3.B Procedural Abstraction
Here, a End Game function is created (first image). The function states the end game conditions and tells the program what to do when the game ends. In the second image, the function is being called twice. This function ends the game depending on the conditions that are stated within the code. This function is essential to the program because it allows for the reload/ restart options
2.B Algorithm Implementation
4.C Testing
In the images above, on of the conditions being tested is whether the game should end or not. If and for methods are used to determine weather the game should end or not. It checks for collisions against the boundaries, running into itself and if every square is filled; if these conditions are met. The game ends.
The update function displayed above is constantly updating the game. One of the things it does is check to see whether new apples should be spawned on the canvas. The function uses if and return to see whether it is time to place a new food on the canvas. It checks to see if the previous apple has been eaten and if the game hasn't ended, then it spawns a new apple.