Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

1. Introduction to Conditionals

  • 1. Introduction to Conditionals
  • 2. Move Athlete Around
  • 3. Make the Ball Sprite Bounce
  • 4. Bounce Off the Athlete
  • 5. Add-Ons
  • 6. Reflection
  • 7. Wrap-up: Net Sports
  • 8. Wrap-up: Share Your Project
  • 9. Wrap-up: Show Your Project
Next arrow_forward
Transcript

Welcome back, team. It’s time for activity 3 of Google CS First Sports. Get pumped to create a fun and exciting Net Sports game of your choice. You can choose tennis, volleyball, or badminton. Fun fact: badminton is technically the fastest sport.

The serving players can hit the birdie up to 206 mph.

In this activity, you’ll use an important computer science concept called conditional statements, also called “if-then” statements. Computers make decisions based on the instructions you give them. The code block that tells a computer to make a decision is called a conditional.

A conditional statement has two parts: the condition and the instructions to run if the condition is true. You can frame the decisions you make in “if” statements. “If it is cold outside, you put on a jacket.” It being cold outside is the condition, and the instruction you run if it is cold is “wear a jacket” In soccer, if you want power, you kick with the front of your foot. If you want accuracy, you kick with the inside of your foot. Computer scientists like you have helped athletes improve their performances with apps that track their movements. When you connect the miCoach Smart Ball from Adidas to a mobile device like a phone or tablet, it keeps track of the speed and spin of the soccer ball after you kick it.

The miCoach app tells you how close to the professional kick you came. If your kick was very close to the pros, you’ll see 5 stars. If it’s much faster or slower, or has too much or too little spin, you can get half a star.

The Zepp sensor does something similar for baseball. When connected to a bat, it tracks the path of that bat and the speed of the swing. If the bat touches the ball, that portion of the swing is colored red. If the batter moves the screen, the app shows the ball from different angles.

As you can see by these examples, the conditionals you will learn today are used in all types of athletic devices.

As you can see, it helps you measure, it helps you motivate, and it helps you maximize your game.

Pretty sweet, huh?

The app connected to those shoes uses a lot of conditionals.

If the athlete taps his or her foot, the app adds “foot fires."

If the athlete jumps, the app uses information from the sensors in the shoes to test how high the jump was. This activity will use conditionals to decide what to do “if” the ball sprite touches a racket. You’ll use the same concept that these gadgets use to help improve athletes’ performances!

Just like in the last activities, you've got a number of sports to choose from. You can choose to work with tennis, volleyball, or badminton – click the link to open the starter project in a new tab. Click “Remix,” and sign in with the username and password on your CS First club pass in your Passport.

Here’s the game plan: First, open the starter project.

Then, remix it, and sign in. Once you've done that, return to this tab, click the "next" arrow, and move on to the next video to start coding your project.

Instructions
  1. Open the starter project.
  2. Remix the project and sign in.