Unit2

# Unit 2 - Course B

For classes that wish to go further, the second 10 hour course builds on the skills students developed in Course A through the development of a simple video game. Students will delve deeper into the intersection of Math and CS by studying topics such as boolean logic, piecewise functions, and collision detection with the Pythagorean Theorem, using these concepts to build supporting functions that will eventually drive the logic in their culminating game.

## Week 1

### Lesson 1: Video Games and Coordinate Planes

• Coordinate Planes
• Video Game Analysis
• Wrap-up

Students discuss the components of their favorite video games and discover that they can be reduced to a series of coordinates. They then explore coordinates in Cartesian space, identifying the coordinates for the characters in a game at various points in time. Once they are comfortable with coordinates, they brainstorm their own games and create sample coordinate lists for different points in time in their own game.

### Lesson 2: The Big Game - Variables

• Getting Started
• Variables in the Big Game

Students get their first look at the inside of their own video games. They will start development by substituting in new Images, Strings, and Numbers for existing variables.

### Lesson 3: The Big Game - Animation

• Getting Started
• Activity

Returning to the Big Game we started in stage 7, students will use the Design Recipe to develop functions that animate the Target and Danger sprites in their games.

### Lesson 4: Booleans and Logic

• Getting Started
• Activity

Booleans are the fourth and final data type that students will learn about in this course. In this stage, students will learn about Boolean (true/false) values, and explore how they can be used to evaluate logical questions.

### Lesson 5: Boolean Operators

• Getting Started
• Activity

Using Boolean operators, students will write code that compares values to make logical decisions.

### Lesson 6: Sam the Bat

• Getting Started
• Activity
• Extension Activities

Using Boolean operators, students will write code that checks the location of a sprite to make sure it doesn't go off-screen.

## Week 1

### Lesson 7: The Big Game Booleans

• Getting Started
• Activity

Using the same logic from the previous lesson, students will write code that checks whether their Target and Danger sprites have left the screen. If their function determines that a sprite is no longer visible on screen, it will be reset to the opposite side.

### Lesson 8: Conditionals and Piecewise Functions

• Getting Started
• Activity

Currently, even when passing parameters to functions, our outputs follow a very rigid pattern. Now, suppose we want parameters with some values to create outputs using one pattern, but other values to use a different pattern. This is where conditionals are needed. In this stage students will learn how conditional statements can create more flexible programs.

### Lesson 9: Conditionals and Update Player

• Getting Started
• Activity
• Extension Activities

Using conditionals, students will write functions and programs that change their behavior based on logical evaluation of input values.

### Lesson 10: Collision Detection and the Pythagorean Theorem

• Getting Started
• Activity

Determining when objects on the screen touch is an important aspect of most games. In this lesson we'll look at how the Pythagorean Theorem and the Distance Formula can be used to measure the distance between two points on the plane, and then decide whether those two points (or game characters) are touching.

### Lesson 11: The Big Game - Collision Detection

• Getting Started
• Activity

To finish up their video games, students will apply what they have learned in the last few stages to write the final missing functions. We'll start by using booleans to check whether keys were pressed in order to move the player sprite, then move on to applying the Pythagorean Theorem to determine when sprites are touching.