CyberPi: Catch the Fish Carnival Game II
In this lesson students will use CyberPi as a controller to move the sprites. Students will also track operational data in a game, and make decisions concerning the results based on the records.

Lesson
Overview
Description
In this lesson students will use CyberPi as a controller to move the sprites. Students will also track operational data in a game, and make decisions concerning the results based on the records.
Objectives
Identify the concept of Motion-Controlled Games and what features they have.
Create a CyberPi controller with which they can change the movements of sprites.
Track the operational data, and decide the result based on the data records.
Program "Catch Fish Carnival Game II" in which players use CyberPi to interact with the game.
Before the Lesson
Prior Experience
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 12 - Catch Fish Carnival Game 2
For students:
Proficiency in block-based coding
Practical knowledge on how to change the sprites' costumes and movements, and use broadcasts.
Already know the rules of Catch Fish Carnival Game, and completed the Catch Fish Carnival Game I project
Review
Warm Up
Objective:
Introduce students to the concept of motion-controlled games.
Procedures:
Explain: Motion-controlled games provide a new way for players to interact with games. Players get more immersed in games by physically interacting with games. Besides, this type of games requires players to move their body, so people have a chance to relax and get some exercise.
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:
Have 1 or 2 students try Catch Fish Carnival Game ll and ask the rest to observe while they're playing. Ask students to figure out what's new about the game compared to Catch Fish Carnival Game I.
Procedures:
Introduce: Last time, we interacted with the Catch Fish Carnival Game via a keyboard. Today, we're going to upgrade the game.
Pick 1 or 2 students to try the game.
Start a class discussion: Compare the upgraded version with the previous one. Are there any differences?
Summarize: The upgraded version adopts a new control method which turns it into a motion-controlled game. Players interact with the game using the CyberPi. When the game is over, it gives you a star ranking and scores based on your success rate. A higher success rate can earn you a higher ranking and more points.
Work with students to analyze what features Catch Fish Carnival Game II should have.
Work with students to draw a mind map.

Independent Practice
Try It!
Objective:
Give students freedom to explore further so that they can enhance their programming skills.
Procedures:
Ask students to open the program file they previously created. If any of the students didn’t complete the program the previous lesson, send them yours.
Add the device CyberPi. Connect CyberPi to mBlock, and switch to Live mode.
Press the button to start the game:
Make sure the data is cleared before the game starts.
The game decides the result based on the player's success rate. Create a variable to track the scooping times:

NOTE:
Add the coding block to the previous script that's written to program the Start button to refresh data.
Wave CyberPi to move the fishing net:
Introduce the motion-sensing block needed to turn CyberPi into a controller:

Use CyberPi to move the fishing net:

Press the joystick to scoop the fish.

When the joystick is pressed, the scooping count is increased by 1.

When the fish is successfully scooped, the score goes up by 1: The scoring system is the same with Catch Fish Carnival Game I so, the script for this part doesn’t need modification.
Game is over when countdown stops
Game over interface:
Ranking: The game uses a star rating system and reward points to measure the player's performance based on the success rate. To raise the threshold, the player will be rated on a scale of stars only when the scooping count exceeds 9.
Success rate = number of fish scooped (score) / scooping count

NOTE:
The example above is the script for a 3-star rating.
Refer to the following table to complete the programs for the whole star rating system:

Display the final score:
Add coding blocks to display the final score

Have students test their program and consider any other effects they could add to the game.
Program a progress bar to display the time left during the game

NOTE:
The sprite Progress Bar has 30 costumes, so program the sprite to switch to another costume ever second.
Display real-time scores:

NOTE:
1. During the game or when the game is over, the score is visually different. So have students set up the position and size properly.
2. Refer to the table below to set up the position and size:

Extensions
Have students try different control sensitivities and different controls for the fishes
Have students try other students programs and provide constructive feedback
Wrap Up
Wrap-Up & Quick Check
Objective:
Have students test each other's programs and games. Let them compete to see who gets the highest score and wins.
Procedures:
Have students invite their classmate or student partner to try their game and compete to see who gets the highest score and wins
Invite 1-3 students to share their experiences and come up with pros and cons.
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.
