CS in Algebra: Big Game Booleans

Alphabets Sounds Video

share us on:

In this lesson, students learn how to use Booleans to keep characters in their video game moving across the screen without disappearing. By creating functions to check if characters are within the screen boundaries, they can ensure that characters reappear on the opposite side when they go off-screen. This lesson builds on previous concepts and enhances the gameplay experience by incorporating logical decision-making through Booleans.

CS in Algebra: Big Game Booleans

Let’s dive back into your exciting video game project! Last time, you made the target and danger characters move across the screen. But there was a little problem—they disappeared and never came back! Today, we’re going to learn how to use something called Booleans to make them return and keep moving across the screen.

What Are Booleans?

Booleans are like little switches in a computer program that can be either true or false. They help us make decisions in our code. For example, if a Boolean is true, we might tell a character to keep moving. If it’s false, we might tell it to do something else, like turn around.

Keeping Characters Onscreen

In a previous lesson, you learned how to keep Sam the Bat from flying out of his backyard. You used Booleans to check if Sam was “Safe Left” and “Safe Right.” Now, we’re going to use a similar idea in your video game.

Every time your target and danger characters move, the game will check their x coordinates—these are numbers that tell us where they are on the screen from left to right. The game will use a special function called Onscreen to see if the characters are still visible. If Onscreen says false, it means the character has gone off the screen, and the game will move it back to the other side.

How to Do It

First, you’ll need to create the Safe Left and Safe Right functions for your characters, just like you did for Sam the Bat. These functions will help you figure out if a character is about to leave the screen on the left or right side.

Once you have those functions ready, you can combine them into the Onscreen function. This will check both sides and keep your characters moving back and forth across the screen, making your game more fun and challenging!

Extra Fun Fact

Did you know that Booleans are named after a mathematician named George Boole? He invented a whole new way of thinking about logic that computers use all the time!

Now you’re ready to make your game even better by using Booleans to keep your characters in action. Have fun coding!

  1. How did the concept of Booleans change your understanding of how video game characters can be controlled and managed within a game environment?
  2. Reflect on a moment when you used Booleans in your coding project. What challenges did you face, and how did you overcome them?
  3. In what ways do you think the use of Booleans can enhance the complexity and interactivity of a video game?
  4. How do you feel about the idea that a simple true or false value can have such a significant impact on the behavior of game characters?
  5. What parallels can you draw between the use of Booleans in coding and decision-making processes in real life?
  6. How might understanding Booleans and their application in games influence your approach to problem-solving in other areas?
  7. What new insights did you gain about the importance of keeping characters onscreen, and how might this affect the overall gaming experience?
  8. How does learning about the historical context of Booleans and George Boole’s contributions to logic and computing inspire your approach to coding?
  1. Create a Boolean Storyboard

    Imagine you are a game designer! Draw a storyboard showing how Booleans help your characters stay on the screen. Use arrows and labels to show when a character should turn around. Share your storyboard with a classmate and explain how Booleans work in your game.

  2. Boolean Logic Puzzle

    Let’s solve a puzzle! Create a simple maze on paper. Use Booleans to decide if a character can move left, right, up, or down. Write down the Boolean conditions for each move. Can you guide your character to the end of the maze?

  3. Code a Character Race

    Use a coding platform to create a race between two characters. Use Booleans to check if they are still on the screen. If a character goes off-screen, use a Boolean to bring it back to the starting line. See which character wins the race!

  4. Boolean Role Play

    In pairs, act out a scene where one of you is a character moving across a screen. The other person uses Booleans to decide if the character should keep moving or turn around. Switch roles and see how Booleans control the action!

  5. Design a Boolean Quiz

    Create a quiz for your classmates with questions about Booleans. Include true or false questions and scenarios where they have to decide what a Boolean would do. Test your classmates and see who knows the most about Booleans!

Here’s a sanitized version of the provided YouTube transcript:

Let’s take another look at your big game. Last time, you animated the target and danger sprites to move across the screen. However, when they left the screen, they never returned! We’re going to use Booleans to bring them back so they move across the screen repeatedly.

In the last stage, you learned how to keep Sam the Bat from leaving his backyard by using a Boolean to check if he was Safe Left and Safe Right. Now, you’ll add the same functionality to your video game. Each time your target and danger move, the game engine will send their x coordinates to the Onscreen function. If Onscreen returns false, that means the sprite has gone off the screen, and the engine will reset it to the opposite side.

Just like you did with Sam the Bat, you’ll want to first complete the Safe Left and Safe Right functions before combining them both in Onscreen.

This version maintains the original meaning while ensuring clarity and professionalism.

BooleansBooleans are a type of data in coding that can only be true or false. – In our game, we use booleans to check if the player has won or lost.

CodeCode is a set of instructions written in a programming language that a computer can understand and execute. – We wrote code to make the robot move forward and backward.

CharactersCharacters are letters, numbers, or symbols that are used in coding and text. – The password must include at least eight characters, including one number.

GameA game is a program designed for entertainment, often involving challenges or puzzles. – We created a simple game where you catch falling stars by moving a basket.

OnscreenOnscreen refers to anything that appears on the computer or device display. – The instructions for the game appeared onscreen as soon as we started it.

SafeIn computing, safe means that something is protected from harm or danger, such as viruses or hackers. – It’s important to keep your computer safe by using strong passwords and antivirus software.

LeftLeft is a direction or position on the computer screen or in a program, opposite of right. – To move the character left, press the left arrow key on your keyboard.

RightRight is a direction or position on the computer screen or in a program, opposite of left. – The player moved right to avoid the obstacles in the game.

CoordinatesCoordinates are numbers that determine the position of a point on a grid or screen. – We used coordinates to place the treasure chest at the correct spot in the game.

TrueTrue is a boolean value that indicates something is correct or has happened. – The condition is true if the player collects all the coins in the level.

All Video Lessons

Login your account

Please login your account to get started.

Don't have an account?

Register your account

Please sign up your account to get started.

Already have an account?