CyberPi: Dodge the Bird I
In this lesson students will understand the role and importance of data in player character selection. Students will draw a mind map to analyze the basic game effects of Dodge the Bird. They will also complete the code using the mind map created.

Lesson
Overview
Description
In this lesson students will understand the role and importance of data in player character selection. Students will draw a mind map to analyze the basic game effects of Dodge the Bird. They will also complete the code using the mind map created.
Objectives
Explain why and how player characters are created.
Draw a mind map to analyze the essential features of Dodge the Bird.
Use variables and create a prototype of Dodge the Bird.
Before the Lesson
Preparation
For the teacher and students:
Computer with mBlock 5 installed from here: https://www.mblock.cc/en/download/ or mBlock Web version
Wi-Fi connection to student devices for IoT connectivity
One CyberPi’s with USB-C cable
Pocket shield (optional)
Example program(s): CyberPi – Lesson 13 - Dodge the Bird 1
For students:
Proficiency in block-based coding
Knowledge of game design process and ability to design basic game mechanics
Review
Warm Up
Objective:
Introduce player character design and its importance in a game.
Procedures:
Ask: Some games offer different playable characters for players to choose from. Have you ever played any such games?
Encourage students to describe the games in detail. Guide them with questions like, "What’s the name of the game?" and "What kind of player characters are available to choose from?"
Summarize: Quite a few games allow players to choose the character they want to control.
Ask: As a player, what do you think about this feature? What if you didn't have the option to choose a character?
Summarize: Providing different characters for players to choose from enriches a game and the player experience but also sustains players' motivation and interest in playing the game.
Direct Instruction
Tour of mBlock 5
1. Open the mBlock software or mBlock 5 Web version.
2. Introduce students to the following key areas of the software interface:


Connect the CyberPi
3. Plug the CyberPi into the computer using the included cable. The CyberPi should boot up and the screen will display either the last program uploaded or the Home menu.
4. On the "Devices" tab in mBlock, click the "Add" button. Select CyberPi and click "Ok".
5. Click the "Connect" button. Then, select the USB port and click "Connect".

6. If connected successfully, the button will change to "Disconnect".

Guided Practice
Hands On
Objective:
Describe what the game is like to students and encourage them to brainstorm how to develop the game.
Procedures:
Invite volunteers to try Dodge the Bird. Have them pay attention to the player character selection page.
Ask: How did the player choose a character in Dodge the Bird? What’s the logic behind the player character selection system? (Hint: if…then…) And describe how to play the game.
Summarize: In the game, the player uses CyberPi's joystick to select a character. Push the joystick to the right to select Witch and push the joystick to the left to select Jinnee. Let's take a look at the gameplay of Dodge the Bird:

Work with students to analyze some features of Dodge the Bird.
Instruct students to draw a mind map.

Independent Practice
Try It!
Objective:
Give students the freedom to explore further so that they can enhance their programming skills.
Procedures:
Connect CyberPi to mBlock and select the Live mode.
Open the demo program file and go through it. The file includes preset programs for:

Click the green flag to enter the startup interface.
The startup interface has been preset with the following script:

Define the initial status of a player character:
Set the initial status of player characters, including location and direction.
Create a variable "lives" and set it to 4. This setting gives a player character four lives. The variable will be later used in the script to determine whether a player loses the game.

Control characters:
Characters move up/down: Tilt CyberPi to make a player character move up or down.

Use the Motion Sensing block in the table to detect which direction CyberPi is tilted to:

CyberPi tilted forward/backward:

NOTE:
Wrap the tilted forward? and tilted backward? blocks into the same forever block.
Sprite movement:

Prevent sprites from moving out of the stage:
If a sprite keeps going up or down, it will disappear from the stage.
To avoid a sprite disappearing, add this sensing block to the script:

Write these scripts:

Both scripts involve two change y by () blocks. Take the script on the left as an example. When receiving Up, the sprite's y-coordinate changes by 10. To prevent the sprite from disappearing, type -10 in the second change y by () block. The second change y by ( ) block will offset the effect of the first one when the sprite touches the edge of the stage.
Set up the penalty system:
If the sprite touches the bird, it loses a life:

Add an animated effect to the life sprite:
To show how many lives the player has left, add a 4-star sprite at the top left corner of the stage. A star represents a life.
The 4-star sprite only appears when the game starts. So, move the sprite to a specified location but hide it at the very beginning.

The 4-star sprite has four costumes and switches costumes to tell the player how many lives are left. When Lives equals 0, the sprite disappears from the stage:

NOTE:
Here's just an example program. Complete the script to make the sprite change costumes accordingly when Lives equals 3, 2, and 1.
Result game over:

Game over effect:
Character falling: When the game is over, the player character stops flying and falls down. Use point in direction ( ) and glide ( ) secs to x: ( ) y: ( ) to mimic the falling effect.

Display Game Over:
A Game Over sign rises from the bottom to the center of the stage.
Highlight the sprite Signs and click Costumes. One of the costumes is Game Over.

Make the Game Over sign appear at the center of the stage:

Extensions
Have students speed up the birds to increase the level of difficulty overtime
Have students add a second bird to increase the level of difficulty overtime
Wrap Up
Wrap-Up & Quick Check
Objective:
Allow students time to play the game that they’ve developed and have them improve the game by considering user preferences.
Procedures:
Invite two volunteers to try the game and compete to see who can survive the longest.
Have students discuss: As a player, do you want other features or effects? What are they?
Downloadable Material
Example Program
Educational Standards
CSTA
CSTA
2-AP-11: Create clearly named variable that represent different data types and perform operations on their values.
2-CS-02: Design projects that combine hardware and software components to collect and exchange data.
2-AP-13: Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
ISTE
ISTE
5c: Students break problems into component parts, extract key information, and develop descriptive models to understand complex systems or facilitate problem-solving.
Alberta - Grade 7-8 - CTF
Grade 7-8
CTF
Planning, creating, appraising and communicating in response to challenges.
Working independently and with others while exploring careers and technology.
British Columbia - Grade 7-8 - ADST
Grade 7
ADST
• Generate potential ideas and add to others’ ideas
• Identify and evaluate the skills and skill levels needed, individually or as a group, in relation to a specific task, and develop them as needed
• Select, and as needed learn about, appropriate tools and technologies to extend their capability to complete a task
Grade 8
ADST
• Generate potential ideas and add to others’ ideas
• Make a plan for production that includes key stages, and carry it out, making changes as needed
• Identify and evaluate the skills and skill levels needed, individually or as a group, in relation to a specific task, and develop them as needed
• Select, and as needed learn about, appropriate tools and technologies to extend their capability to complete a task
Manitoba - Grade 7-8 - Science
Grade 7
Science (Overall Skills and Attitudes)
7-0-4a Carry out procedures that comprise a fair test. Include: controlling variables, repeating experiments to increase accuracy and reliability.
7-0-4c Work cooperatively with team members to carry out a plan, and troubleshoot problems as they arise.
Grade 8
Science (Overall Skills and Attitudes)
8-0-4a Carry out procedures that comprise a fair test. Include: controlling variables, repeating experiments to increase accuracy and reliability.
8-0-4c Work cooperatively with team members to carry out a plan, and troubleshoot problems as they arise.
New Brunswick - Grade 7-8 - Science
Grade 7-8
Science (Attitude Outcome)
425 show a continuing curiosity and interest in a broad scope of science-related fields and issues
430 persist in seeking answers to difficult questions and solutions to difficult problems
431 work collaboratively in carrying out investigations, as well as in generating and evaluating ideas
Newfoundland & Labrador - Grade 7-8 - Science
Grade 7-8
Science
GCO: Skills - Students will develop the skills required for scientific and technological inquiry, for solving problems, for communicating scientific ideas and results, for working collaboratively, and for making informed decisions.
Nova Scotia - Grade 7-8 - ICT & Mathematics
Grade 7
Technology
GCO1: Students will be expected to design, develop, evaluate, and articulate technological solutions.
GCO2: Students will be expected to operate and manage technological systems.
Mathematics
PR05 Students will be expected to evaluate an expression given the value of the variable(s).
Performance Indicator:
PR05.01 Substitute a value for an unknown in a given expression and evaluate the expression.
PR02 Students will be expected to create a table of values from a linear relation, graph the table of values, and analyze the graph to draw conclusions and solve problems.
G02 Students will be expected to identify and plot points in the four quadrants of a Cartesian plane, using integral ordered pairs.
Performance Indicators:
G02.01 Label the axes of a four quadrant Cartesian plane and identify the origin.
G02.02 Identify the location of a given point in any quadrant of a Cartesian plane using an integral ordered pair.
G02.03 Plot the point corresponding to a given integral ordered pair on a Cartesian plane with units of 1, 2, 5, or 10 on its axes.
Grade 8
Technology
GCO1: Students will be expected to design, develop, evaluate, and articulate technological solutions.
GCO2: Students will be expected to operate and manage technological systems.
Ontario - Grade 7-8 - Mathematics
Grade 7
Mathematics
Algebra
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves events influenced by a defined count and/or sub-program and other control structures
Grade 8
Mathematics
Algebra
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves the analysis of data in order to inform and communicate decisions
Prince Edward Island - Grade 7-8 - Science
Grade 7-8
Science
GCO: Skills - Students will develop the skills required for scientific and technological inquiry, for solving problems, for communicating scientific ideas and results, for working collaboratively, and for making informed decisions.
Quebec - Grade 7-8 - Science
Grade 7-8
Science (Strategies)
Exploring various ways of solving the problem
Exchanging information
Comparing different possible explanations for or solutions to a problem in order to assess them (e.g. full-group discussion)
Saskatchewan - Grade 7-8 - Science
Grade 7-8
Science (Goals)
Develop Scientific and Technological Skills – Students will develop the skills required for scientific and technological inquiry, problem solving, and communicating; for working collaboratively; and for making informed decisions.
