Skip to content

Please update your browser

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

https://storage.googleapis.com/files.cs-first.com/sports/sports-icon%402x.png

1. Introduction to Conditionals

Transcript

(instrumental music)

Welcome back, team.

It's time for activity three 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.

A fun fact about badminton, it's technically the world's fastest sport.

The serving players can hit the birdie up to 206 miles per hour.

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 the 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 to 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 performance with apps that track their movements.

When you connect the miCoach Smart Ball from Adidas to a mobile device like a phone or a tablet, it keeps track of the speed, and the spin of a 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 five stars.

If it's much faster or slower, or it's got too much spin or too little, you can get half a star.

The zub sensor does something similar for baseball.

When connected to a bat, it tracks the path the bat takes, 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.

And so, I want you to show them some things, moving back and forth.

Alright, so, 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 just 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 athletes improve their performances.

Just like in the last activity, 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 the new tab, and sign in with your user name and password on your CS First Club Passport, click Remix.

Alright, here's the game plan.

First, open the starter project, and sign in, then Remix it.

Once you've done that, return to this tab, click the next arrow, and move onto the next video to start coding your project.

Instructions
  1. Open the starter project.
  2. Remix the project and sign in.
Attributions
  • miCoach by Adidas Micoach (http://micoach.adidas.com/smartball)
  • NIKE+ Basketball & NIKE+ Training - Launch & Demos Feb 2012 by Red Robot - Intelligent Distribution (https://www.youtube.com/watch?v=zqaf51xNBLk) licensed under CC-BY 3.0 (http://creativecommons.org/licenses/by/3.0/)
  • Zepp Baseball Training Tool Launch Demonstration - ZeppTraining.com by SkillTrax Training 1 (https://www.youtube.com/watch?v=gZjDcX66EV0) licensed under CC BY-NC 3.0 (http://creativecommons.org/licenses/by-nc/3.0/)