How to program snake on Ti-84 Plus CE

Chief Dylan Programming
25 Nov 202129:39
EducationalLearning
32 Likes 10 Comments

TLDRThis video tutorial guides viewers through programming a snake game on a TI-84 Plus CE calculator. The presenter demonstrates how to create the game, explaining each step, from initializing variables to setting game conditions. The snake grows with food consumption, and the game ends if the snake hits the screen edge or itself. The video promises a bonus video if it gets 100 likes by Christmas 2021 and provides the snake game's download and source code in the description. It also invites viewers to check out a previously created Pong game program.

Takeaways
  • ๐ŸŽฎ The video is a tutorial on programming a snake game on a TI-84 Plus CE calculator.
  • ๐Ÿ”‘ The snake's body is represented by zeros, and the food is indicated by a star sign in the game.
  • ๐Ÿ“ˆ The snake grows longer each time the player eats food, and the game ends if the snake hits the screen edge or itself.
  • ๐ŸŽ The video creator promises a bonus video if the video gets 100 likes by Christmas 2021, and the source code is available in the description.
  • ๐Ÿ† The game is won by reaching a score of 200, which represents the length of the snake.
  • ๐Ÿ› ๏ธ The program is approximately 64 lines long, with the first 10 lines being relatively simple and the rest containing longer segments.
  • ๐Ÿ”ข Variables are used extensively in the program, including coordinates for the snake and tail, direction, score, and a death boolean.
  • ๐Ÿ”„ The program includes loops and conditionals to manage the snake's movement, growth, and collision detection.
  • ๐Ÿ“š The tutorial provides step-by-step instructions for entering each line of code into the calculator's program editor.
  • ๐Ÿ”„ The 'get key' command is used to capture user input for controlling the snake's direction.
  • ๐ŸŽ‰ The video concludes with the successful execution of the snake game, displaying the game over message and score when the game ends.
Q & A
  • What is the main topic of the video?

    -The main topic of the video is programming a snake game on a TI-84 Plus CE calculator.

  • What is the significance of the zeros and star sign in the snake game?

    -In the game, zeros represent the body of the snake, and the star sign represents the food that the snake eats to grow longer.

  • What is the condition for winning the snake game as mentioned in the video?

    -The snake game is won when the snake's length reaches 200 units.

  • What incentive does the video creator offer for the video to reach 100 likes by Christmas of 2021?

    -The video creator promises to post a bonus video if the video gets 100 likes by Christmas of 2021.

  • Where can viewers find the download and source code for the snake game?

    -The download link and source code for the snake game can be found in the video description.

  • What is the first step in creating a new program on the TI-84 Plus CE as per the video?

    -The first step is to press the PRGM button, scroll over to NEW, and press enter to create a new program.

  • What does the variable 'g' represent in the snake game program?

    -In the snake game program, 'g' represents the get key command, which is the value of the button being pressed.

  • What is the purpose of the 'for' loop in the snake game program?

    -The 'for' loop in the snake game program is used to repeat a set of instructions a certain number of timesโ€”in this case, five timesโ€”to set up the initial conditions for the game.

  • What command is used to clear the home screen on the TI-84 Plus CE calculator?

    -The 'clear home' command, accessed through the I/O menu, is used to clear the home screen on the TI-84 Plus CE calculator.

  • What does the video creator suggest for viewers who want a more in-depth explanation of the snake program?

    -The video creator suggests that if viewers want a more in-depth explanation of the snake program, they should leave a comment, and the creator will consider making a follow-up video.

  • How does the snake game handle the snake running into itself?

    -The snake game includes conditions to check if the snake is running into itself by ensuring that new food does not fall onto the snake's body and by storing the tail's position to prevent the snake from moving back onto it.

  • What is the purpose of the 'while' loop in the snake game program?

    -The 'while' loop in the snake game program is used to continuously run the game as long as the snake is alive, which is determined by the death boolean 'c'.

  • How does the game check if the snake is staying within the screen boundaries?

    -The game uses a series of 'if' conditions to check if the snake's coordinates (x and y) are within the screen boundaries (1 to 26 for x and 1 to 10 for y). If the snake goes outside these boundaries, the game ends.

  • What is the role of the 'get key' command in the snake game?

    -The 'get key' command is used to capture the user's key press, allowing the snake to change direction based on the arrow keys pressed by the player.

  • What happens when the snake eats food in the game?

    -When the snake eats food, the score 's' is incremented by one, and the tail boolean 't' is set to 1, indicating that the tail needs to grow.

  • How does the game display the snake's tail?

    -The game uses the coordinates of the tail (v and u) to output spaces on the screen, creating the appearance of the snake's tail.

  • What is the purpose of the 'implicit conditionals' in the program?

    -Implicit conditionals are used to perform operations based on the snake's direction without using traditional 'if' statements. They save space and make the program run faster by condensing the 'if' commands.

  • How does the game handle the end of the game?

    -When the snake dies or reaches a length of 200, the game displays 'Game Over' and the final score on the screen.

  • What is the final step to run the snake game on the TI-84 Plus CE calculator?

    -The final step is to press the EXEC button (which stands for execute) to run the snake game.

Outlines
00:00
๐ŸŽฎ Introduction to Programming Snake on TI-84 Plus CE

The video script introduces a tutorial on how to program a snake game on a TI-84 Plus CE calculator. The presenter demonstrates the snake game, explaining the game mechanics such as growing the snake by eating food, and the consequences of hitting the screen edge or the snake's body. The tutorial offers a bonus video incentive for likes and provides the snake game's download and source code in the video description. It also promotes the presenter's previous 'pong' game program and encourages viewers to check it out.

05:05
๐Ÿ›  Setting Up the Snake Game Environment

This paragraph details the initial steps for setting up the snake game development environment on the TI-84 Plus CE calculator. It explains how to access the program editor, create a new program named 'snake', and input the first ten lines of code that involve storing variables essential for the game's functionality. These variables include 'g' for the get key command, 'c' for the death Boolean, 's' for the score, 'x' and 'y' for the snake's coordinates, 'v' and 'u' for the tail's coordinates, 'd' for the snake's direction, and 't' for the tail Boolean.

10:09
๐Ÿ”ข Creating and Populating the Game Board

The script continues with instructions on how to delete and create a matrix named 'a' with dimensions 10 by 26, which corresponds to the game screen size. It then describes using a for loop to generate five random food items on the board, represented by the number 5 in the matrix. The food's coordinates are determined by random integer commands, and the food is displayed on the screen using output commands.

15:14
๐Ÿ” The Main Game Loop and Snake Movement

The paragraph explains the implementation of a while loop that runs as long as the snake is alive, signified by the death Boolean 'c'. It details the process of displaying the snake's head on the screen using the snake's coordinates 'y' and 'x'. The script also includes an if conditional to increase the score 's' and visually grow the snake by setting the tail Boolean 't' when the snake eats food. Additionally, it sets up another while loop to place new food on the screen, ensuring the food doesn't appear on the snake and maintains an enjoyable gameplay experience.

20:14
โš ๏ธ Game Over Conditions and Direction Controls

This section of the script discusses the conditions that lead to the snake's death, such as running into itself or reaching a body length of 200, which is a win condition. It also outlines the get key commands to handle user input for snake movement and uses if conditionals to change the snake's direction without causing it to reverse into itself. The paragraph ensures the snake's movement is restricted within the screen boundaries to prevent errors.

25:15
๐Ÿ Tail Movement and Game Logic

The script explains the use of implicit conditionals to control the tail's movement based on the snake's direction. It details how to update the tail's coordinates 'u' and 'v' and how to manage the tail's appearance to avoid the snake running into itself. The paragraph also includes steps to output spaces at the tail's previous position to give the illusion of a retracting tail as the snake moves.

๐Ÿ† End Game Conditions and Score Display

The final part of the script describes the end-game conditions, such as displaying 'game over' and the player's score when the snake dies or wins by reaching a length of 200. It provides instructions for outputting the words 'game over' and 'you win' at specific screen coordinates, along with the player's score. The script concludes with how to exit the program editor and run the completed snake game.

Mindmap
Keywords
๐Ÿ’กTI-84 Plus CE
The TI-84 Plus CE is a graphing calculator produced by Texas Instruments, known for its advanced features and color screen. In the video, it is the platform on which the snake game is being programmed, demonstrating the calculator's capability to run complex programs beyond basic mathematical functions.
๐Ÿ’กSnake Game
The snake game is a classic video game where players control a line which grows in length as it eats food, with the objective to avoid hitting the screen edges or itself. In the script, the game is the central focus, with the creator guiding viewers through the process of programming this game on a TI-84 Plus CE calculator.
๐Ÿ’กProgram Editor
The program editor is the interface within the TI-84 Plus CE where users can write and edit programs. The script mentions entering the program editor to start coding the snake game, highlighting the step-by-step process of creating lines of code.
๐Ÿ’กVariables
In programming, variables are used to store data that can be changed or manipulated during the execution of a program. The script discusses storing variables like the snake's coordinates, direction, and score, which are essential for the game's logic and functionality.
๐Ÿ’กMatrix
A matrix in the context of this video refers to a two-dimensional array of values used within the program. The script describes creating and using a matrix to manage the game board, including the positions of the snake and the food.
๐Ÿ’กFor Loop
A for loop is a control flow statement that allows code to be executed repeatedly based on a given condition. The script explains using a for loop to repeat certain actions, such as placing multiple pieces of food on the game board.
๐Ÿ’กConditional Statements
Conditional statements, such as if-else statements, are used to perform different actions based on whether a condition is true or false. The script includes examples of conditionals to check for winning the game, handling user inputs, and determining the snake's movement.
๐Ÿ’กGet Key Command
The get key command is used to detect which key is pressed by the user, allowing for interactive control within the program. In the script, it is used to capture the user's input for moving the snake in different directions.
๐Ÿ’กBoolean
A Boolean is a data type that can only have two values: true or false. The script uses a Boolean variable to represent the snake's state, such as whether it is alive or dead, affecting the flow of the game.
๐Ÿ’กImplicit Conditionals
Implicit conditionals are a shorthand way of writing if-else statements, often used to save space in code. The script mentions using implicit conditionals to adjust the snake's coordinates based on its direction, streamlining the coding process.
๐Ÿ’กGame Over
Game over is a term used to indicate the end of a game session, typically when the player has failed or completed the game. In the script, the phrase is used to describe the output displayed when the snake hits the screen edge or itself, signaling the end of the game.
Highlights

Introduction to programming a snake game on the TI-84 Plus CE calculator.

Demonstration of the snake game with the snake represented by zeros and food by a star sign.

Explanation of game mechanics, including snake growth upon eating food and game over conditions.

Incentive for viewers to like the video for a chance to see a bonus video by Christmas 2021.

Availability of download and source code in the video description for those interested in the program.

Promotion of the creator's previous Pong game program with a link provided in the description.

Emphasis on the educational aspect of the snake game program to enhance programming understanding.

Instructions on how to access the program editor and create a new program named 'snake'.

Overview of the first 10 lines of code, which are crucial for setting up variables.

Description of the variables used in the program, such as 'g' for the get key command and 'c' for the death Boolean.

Guidance on deleting and creating matrices for the game's environment setup.

Use of a for loop to place multiple pieces of food on the screen simultaneously.

Implementation of a while loop to maintain the game's ongoing state based on the snake's life status.

Conditionals to check for collisions with the snake's body or the screen edges, resulting in game over.

Instructions on how to output the snake's tail and manage its appearance on the screen.

Details on using implicit conditionals to control the snake's movement directions efficiently.

Final steps to display 'Game Over' and the player's score when the snake dies or wins by reaching 200.

Completion of the snake game program and instructions on how to run it on the calculator.

Transcripts
Rate This

5.0 / 5 (0 votes)

Thanks for rating: