Lesson 27: Project - Design a Game

Overview

Question of the Day: How can the five CS practices (problem solving, persistence, communication, collaboration, and creativity) help programmers to complete large projects?

Students will plan and build their own game using the project guide from the previous two lessons. Working individually or in pairs, students will first decide on the type of game they'd like to build, taking as inspiration a set of sample games. They will then complete a blank project guide where they will describe the game's behavior and scope out the variables, sprites, and functions they'll need to build. In Code Studio, a series of levels prompts them on a general sequence they can use to implement this plan. Partway through the process, students will share their projects for peer review and will incorporate feedback as they finish their game. At the end of the lesson, students will share their completed games with their classmates. This project will span multiple classes and can easily take anywhere from 3-5 class periods.

Purpose

This lesson is the culmination of Unit 3 and provides students an opportunity to build a Game Lab project of their own from the ground up. The scaffolding provided by the project guide and the practice they have using it are intended to assist students in scoping their projects and seeing their ideas through to completion. This project is an opportunity to showcase technical skills, but they will also need to collaborate with their partner, provide constructive peer feedback, and repeatedly use the problem solving process as they encounter obstacles along the way. This project should be student-directed whenever possible, and provide an empowering and memorable conclusion to this unit of CS Discoveries.

Assessment Opportunities

Use the project rubric attached to this lesson to assess student mastery of learning goals of this unit. You may also choose to assign the post-project test through Code Studio.

Agenda

Lesson Modifications

Warm Up (5 min)

Activity (100-200 min)

Wrap Up (10 min)

Post-Project Test

View on Code Studio

Objectives

Students will be able to:

  • Independently scope the features of a piece of software
  • Create a plan for building a piece of software by describing its major components
  • Implement a plan for creating a piece of software

Preparation

  • Print copies of the project guide, one for each student / pair of students
  • Print copies of the rubric, one for each student / pair of students
  • Print copies of the peer review guide, one for each student / pair of students
  • Review sample games in Code Studio

Links

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

For the Teachers

For the Students

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)

Discussion Goal

This discussion serves to set cultural norms for the project. Students should expect that the project will be challenging, but that they will have plenty of opportunities to iterate on their work as they work together to learn as a community.

Prompt: Today, you'll start the final project of the unit, in which you will design and code your own game. Before you start, what are three skills or qualities that you think will be important as you complete this project?

Share: Allow students to share out their ideas.

Remarks

There are lots of practices that programmers use when working on large projects. As you design and build your game, try to reflect on how you are using the five practices of problem solving, persistence, communication, collaboration, and creativity.

Question of the Day: How can the five CS practices (problem solving, persistence, communication, collaboration, and creativity) help programmers to complete large projects?

Activity (100-200 min)

Review Project Guide

Group: This project can be completed individually or in pairs. At your discretion, you may choose to have students form larger groups as well.

Distribute: Each student or group of students should be given a copy of the project guide. As a class, review the different steps of the project and where they appear in the project guide. Direct students towards the rubric so that they know from the beginning what components of the project you will be looking for.

Define - Scope Game

Circulate: Students should spend the first 15-20 minutes playing the sample games, reviewing past work, and discussing as a group the type of game they'd like to build. If they want they can sketch ideas on scratch paper or in their journals.

Prepare - Complete Project Guide

Circulate: Once students have discussed their ideas for the project, they should complete the project guide. While this should be a fairly familiar process, encourage students to make each component as clear and detailed as they can. Planning ahead can help them identify issues in their plan before they'll need to make more significant changes to their code.

Try - Write Code

Transition: Students are now ready to program their games on Code Studio. These levels provide some guidance on how students may go about implementing their project guide. None of the steps are significantly different from what students have seen from the previous two lessons. If they wish, students can work in a different order than the one suggested in these levels.

Reflect - Peer Review

Distribute: Give each student a copy of the peer review guide.

Students should spend 15 minutes reviewing the other group's game and filling out the peer review guide.

Iterate - Update Code

Circulate: Students should complete the peer review guide's back side and decide how to respond to the feedback they were given. They should then use that feedback to improve their game.

Share

Share: Give students a chance to share their games. If you choose to let students do a more formal presentation of their projects, the project guide provides students a set of components to include in their presentations including:

  • The original game they set out to build
  • A description of the programming process including at least one challenge they faced and one new feature they decided to add
  • A description of the most interesting or complex piece of code they wrote
  • A live demonstration of the actual game

Wrap Up (10 min)

Journal

Question of the Day: How can the five CS practices (problem solving, persistence, communication, collaboration, and creativity) help programmers to complete large projects?

Prompt: Have students reflect on their development of the five practices of CS Discoveries (Problem Solving, Persistence, Creativity, Collaboration, Communication). Choose one or more of the following prompts as you deem appropriate.

  • Choose one of the five practices in which you believe you demonstrated growth in this unit. Write something you did that exemplified this practice.

  • Choose one practice you think you can continue to grow in. What’s one thing you’d like to do better?

  • Choose one practice you thought was especially important for the project we completed today. What made it so important?

Reflect

Send students to Code Studio to complete their reflection on their attitudes toward computer science. Although their answers are anonymous, the aggregated data will be available to you once at least five students have completed the survey.

Post-Project Test

The post-project test is found at the bottom of the Interactive Animations and Games unit overview page on Code Studio (studio.code.org/s/csd3-2020).

This test is locked and hidden from student view by default. In order for students to see and take this test, you'll need to unlock it by clicking the "Lock Settings" button and following the instructions that appear.

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

Teaching Tip

Student Instructions

  • Design Your Game
  • 2
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Create your own game

Now that you have all the skills you need, it's time to make your own game!

With a partner, brainstorm some different ideas for your game. You can think about the games you've already seen, or look at some more sample games to give you ideas.

Once you have settled on a type of game with your partner, fill out the Project Guide with the backgrounds, variables, sprites, and functions that you will need to make the game. You'll spend the next few levels creating your game.

  • Project - Background and Variables
  • 3
  • 4
  • 5
  • 6
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Create your Variables

First, you'll need to create all of your variables and put them in the variables area of your code. Show me the block Show me the area in the code

Don't forget, each variable needs a label (name) and a starting value. You can change the value of the variable later in your code.

View on Code Studio

Student Instructions

Create your Backgrounds

Next, you'll create all of the background functions that you need for your game. Some games only have one background, and others have more than one that's chosen according to user score or another aspect of gameplay. You'll need to create a function for each separate background in your game. You'll write the code to choose the correct background in the next level.

After you create your functions, test them by calling them inside the draw loop, one background per test.

View on Code Studio

Student Instructions

Display Boards

Now that your backgrounds are working, you can add your display boards. Most games have a score board, but you might also want to display information about player level or lives remaining. Look at Lesson 17 Level 7, Sublevel 2 for an example of how to make a scoreboard.

For each display board: Create a function to display the information Call the function in the draw loop

Be sure to test your boards by changing the starting value of your variables and making sure the board also changes when you run the code.

View on Code Studio

Student Instructions

Choose your Backgrounds

Now that you have the backgrounds that you need, you'll write the code to choose the correct background. You've seen this done in Lesson 24 Level 10.

After you've written the code, test it by changing the starting value of your variables and making sure the correct background shows up.

View on Code Studio

Student Instructions

Create your Animations

Next you will create your animations in the animation tab. Don't forget to make multiple animations if you want your sprite to change appearance according to how it's moving.

View on Code Studio

Student Instructions

Create your Sprites

Next you will create your sprites and give them starting properties in the "Create Sprites" area of your code. For each sprite your should:

  • Create the sprite in the correct place on the screen
  • Set its animation (or color and size)
  • Set its velocity and rotation speed, if needed
  • Set its collider and bounciness, if needed

After you create each sprite, test it before making the next one. If your sprite starts off screen, first place it on the screen to test it, them move it back off screen once you know that it looks right.

If your sprite's position will need to be reset later in your game, it's a good idea to make a function that sets the position of this sprite that you can use again later.

View on Code Studio

Student Instructions

Sprite Movement Functions

Now you'll make the functions that make the sprite move in different ways as the game is played. Some examples of functions that you've written are loopPlatforms in Lesson 26 Puzzle 9 and playerFall in Lesson 26 Puzzle 14.

For each movement: Create a function that will make the sprite move in that way Call the function inside the draw loop

View on Code Studio

Student Instructions

User Controls

Next, you'll want to make sure your user controls are working. Create a function that makes your sprites respond to user controls as defined in your project guide. You can use the function in in Lesson 26 Puzzle 13 as an example.

View on Code Studio

Student Instructions

Sprite Interactions

The last step is to create the functions that make your sprites interact in the right ways. You'll need a function for each type of sprite interaction. You can use the collectItems in Lesson 26 Puzzle 17 and displaceEnemies in Lesson 25 Puzzle 12 as examples.

For each interaction: Create a function in the functions area of your code Call the function inside the draw loop

After you make each function, run the code to test it before making another.

  • Review Your Game
  • 12
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Review Your Game

Look over the rubric and your project guide to make sure your game has everything it needs.

  • Have you included comments in your code?
  • Do you use functions to organize your code and make it easier to read?
  • Do the functions and variables have meaningful names?
  • Are you using conditionals and sprite interactions to make the game more interesting?
  • Reflection
  • 13
  • (click tabs to see student view)
View on Code Studio

Student Instructions

This level is an assessment or survey with multiple questions. To view this level click the "View on Code Studio" link.

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
  • 2-AP-10 - Use flowcharts and/or pseudocode to address complex problems as algorithms.
  • 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-15 - Seek and incorporate feedback from team members and users to refine a solution that meets user needs.
  • 2-AP-16 - Incorporate existing code, media, and libraries into original programs, and give attribution.
  • 2-AP-17 - Systematically test and refine programs using a range of test cases.
  • 2-AP-18 - Distribute tasks and maintain a project timeline when collaboratively developing computational artifacts.
  • 2-AP-19 - Document programs in order to make them easier to follow, test, and debug.