Lesson 23: Mini-Project - Flyer Game

Overview

Question of the Day: How can the new types of collisions and modeling movement be used to create a game?

Students use what they have learned about simulating gravity and the different types of collisions to create simple flyer games. After looking at a sample flyer game, students brainstorm what sort of flyer games they would like, then use a structured process to program the game in Code Studio.

Purpose

This lesson is a chance for students to get more creative with what they have learned. Encourage students to spend time on parts of the activity that interest them, as long as they meet the requirements of the assignment.

Agenda

Lesson Modifications

Warm Up (5 min)

Activity (35 min)

Wrap up (5 min)

View on Code Studio

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the Teachers

For the Students

Support

Report a Bug

Teaching Guide

Lesson Modifications

Attention, teachers! If you are teaching virtually or in a socially-distanced classroom, please see these modifications for Unit 3.

Warm Up (5 min)

Review

Ask students to think of all of the things that they have learned how to do in the unit so far, and display their answers to the class. This is a good time to check in on any concepts that have been challenging for students.

Remarks

You've already learned all of the sprite interactions and types of movement that we will cover this unit. Today you'll have a chance to put them all together to make a flyer game.

Question of the Day: How can the new types of collisions and modeling movement be used to create a game?

Activity (35 min)

Distribute: (Optional) pass out copies of the project guide. Students can use this sheet to plan out the Flyer Game they create at the end of this lesson, but the planning can also be completed on scratch paper.

Transition Send students to Code Studio.

Wrap up (5 min)

Share Out and Journal 3-2-1

Share: Allow students time to play each other's flying games. Ask them to focus not just on the new behavior that they added but also the code they used to create it.

Journal: Have students write and reflect about the following prompts.

  • What are three things you saw in someone else's game that you really liked?
  • What are two improvements you'd make to your game if you had more time?
  • What's one piece of advice you'd give to someone making this type of game?

Question of the Day: How can the new types of collisions and modeling movement be used to create a game?

  • Lesson Overview
  • 1
  • (click tabs to see student view)
View on Code Studio

Teaching Tip

Student Instructions

  • Intro to Flyer Game
  • 2
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Flyer Game

In this flyer game, the player tries to collect coins, and the rocks push the player across the screen. When the player goes off the screen, the game is over.

Play the game a few times and discuss it with your partner. You have already learned all the skills you need to code this game. You'll be making your own flyer game in this mini-project.

  • Make Your Sprites
  • 3
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Create Your Sprites

First create the sprites you will use in your program. You already have a player sprite, but you can change its animation.

You'll need a player (the flyer), a target (the coin), and two obstacles (the rocks). You can make them anything you want.

Do This

  • Go to the animation tab and make sure that you have the images that you want.
  • The flyer, coin and rock are already there, but you can use whatever images you want.
  • Find the code comment GAME SETUP.
  • Create three more sprites: the target and two obstacles.
  • Set each sprite to the animation you chose for it.
  • Scale each one to the size you want.
  • Place them where you want them to be on (or off) the screen.
  • In the game, the obstacles and coin were placed randomly, but you don't need to do that yet.
  • Set the starting x velocity of the obstacles.
  • Test your program. The player and target should be on the screen, and the obstacles should start off screen and move across the screen from left to right and up to down.
  • Player Controls
  • 4
  • 5
  • 6
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Falling

If the user doesn't do anything, the player sprite should fall.

Do This

  • Find the code comment FALLING.
  • Use the counter pattern to with the player sprite's velocityY to make the flyer fall.
  • Test your code to make sure that it works. The sprite should fall faster as it goes down the screen.
View on Code Studio

Student Instructions

Jumping

Next, the player sprite needs to jump when the user presses the "up" arrow.

Do This

  • Find the code comment PLAYER CONTROLS
  • Add a conditional (if block) that checks whether the user is pressing the "up" arrow.
  • Add code inside the conditional that will change the sprite's velocity to move up if the "up" arrow is pressed.
  • Test your code to see whether it works.
View on Code Studio

Student Instructions

Floating Left and Right

The flyer should also be able to float left and right.

Do This

  • Find the code comment PLAYER CONTROL
  • Add a conditional that decreases the sprite's x velocity when the "left" arrow is pressed.
  • Add a conditional that increases the sprite's x velocity when the "right" arrow is pressed.
  • Hint: Your code should use a counter pattern and the velocityX block.
  • Test your code to make sure it works.
  • Sprite Movement
  • 7
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Looping

When the obstacles move off the screen, they should loop back to the other side, at a random position.

Do This

  • Find the code comment LOOPING
  • Add a conditional that checks the horizonal obstacle's x property to see whether it has moved off the screen.
  • If it has moved off the screen...
  • Reset its x property to "loop" it back to the other side of the screen
  • Set its y property to a random number between 50 and 350.
  • Test your code to make sure the first obstacle loops.
  • Add a conditional that checks the vertical obstacle's y property to see whether it has moved off the screen.
  • If it has moved off the screen...
  • Loop it back to the other side of the screen
  • Set its y property to a random number between 50 and 350
  • Sprite Interactions
  • 8
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Sprite Interactions

When your character touches the coin you should reset it somewhere on the screen, and the obstacles should push the player across the screen.

Do This

  • Find the code comment SPRITE INTERACTIONS and read the comments in that section.
  • Create a conditional that checks whether the player is touching the target, and moves the target to the random place if it's true.
  • Create two new collisions that make the two obstacles push the player across the screen.
  • Test your code to make sure it works.
  • Review Your Game
  • 9
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Review Your Game

Test your game to make sure it has everything it needs.

Do This

  • Play your game several times.
  • Read over your project guide and check that you have followed your plan.
  • Make any last changes.

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
  • 2-AP-11 - Create clearly named variables that represent different data types and perform operations on their values.
  • 2-AP-12 - Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.
  • 2-AP-13 - Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
  • 2-AP-17 - Systematically test and refine programs using a range of test cases.
  • 2-AP-19 - Document programs in order to make them easier to follow, test, and debug.