← Back to Library
Lesson PlanFreeEN

CyberPi: Opposite Game

In this lesson students will continue to build on their knowledge of game creation and design. Students will use variables and lists to establish rules for an opposite game and decision game results.

Gr. 7–8
CyberPi: Opposite Game

Lesson

Overview

Description

In this lesson students will continue to build on their knowledge of game creation and design. Students will use variables and lists to establish rules for an opposite game and decision game results.

Objectives

  • Explain the roles of data in designing game mechanics and develop a simple game.

  • Use variables and lists to establish rules for an opposite game and write programs to decide the game results.

  • Draw mind maps to analyze how to develop an opposite game.

  • Improve reaction time and reverse thinking skills by designing and developing the game.

Before the Lesson

Preparation

For the teacher and students:

Example program(s): CyberPi – Lesson 10 - Opposite Game

For students:

  • Proficiency in block-based coding

  • Prior knowledge of CyperPi's major features

  • Capable of displaying texts and images

  • Basic understanding variables and lists

Review

Warm Up

Objective:

  • Engage students in a fun warmup activity, the Opposite Game. Encourage them to think about how the decision system of the game works.

Procedures:

  • Ask students to do the opposite of your commands. For example, when you say "look up", students should look down; when you say "lift your right hand", they should lift their left hand. Tell students the correct action after they perform an action.

  • Ask: The opposite game can improve reaction time and concentration. Now, I want you to recap how we decided whether an action was correct.

  • Summarize: In the opposite game, every command has a designated action, like stand up and sit down. If you do the opposite of the command, then you do the correct action. Many games adopt a similar method to decide the results, comparing players' actions with the preset designated actions. If a player's actions match the actions set in the system, then the player wins 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:

  • Have students brainstorm how a game decides whether a player wins.

Procedures:

  • Introduce the task: We’re going to use the same decision mechanism to develop a simple opposite game.

  • Ask: How do we decide whether a player wins or loses the game?

  • Summarize: When a command comes up, the player needs to perform an action. If the player does the opposite of the command within the given time, then the player wins the game. If the player fails to do the opposite or the time is up, then the player loses the game.

  • Work with students to analyze the game mechanics.

  • Show the mind map to students.

Independent Practice

Try It

Objective:

  • Give students the freedom to explore further so that they can enhance their programming skills.

Procedures:

  • Open mBlock, add CyberPi in"Devices, connect CyberPi to mBlock, and select Live mode.

  • To make it easier to check whether players' actions match the designated ones, create a list command to store the commands.

  • Add four commands to the list: up, down, left, and right

Press the button to start a game:

  • The game begins:

NOTE:

1. Use the variable score to record a player’s scores. 

2. Use the variable time to set the time limit. Set time to 2. If players fail to do an action in 2 seconds, they lose the game. 

Display commands:

  • The game starts when the button is pressed. CyberPi should display a command as the game starts.

NOTE:

1. To make sure players are clear about which command to follow, clear the screen every time before displaying the next command.

2. Use the variable CommandNo to match the number of each item in the "commands list. As the list includes four commands, pick a random number between 1 and 4 to display the commands randomly.

3. Include a broadcast ( ) and wait block in this script to report the decision about whether the player makes the right action before the next command comes up.

  • Push the joystick to the direction opposite to the command

  • If the player does the opposite of the command within the given time, then the player wins the game.

  • If the player does the same as the command or if the time is up, then the player loses the game.

NOTE:

1. The example program includes the decision system for the up command. Complete the programs for the rest commands. When CommandNo equals 1, the command is up. If the player manages to push down the joystick within the given time, then the player makes a correct action and wins the game. If the player pushes the joystick to other directions or if the time is up, the player loses the game.

2. If the player's action is correct, stop the script and display another command. If the player’s action is wrong, the game is over.

3. To check whether a player performs the action within the given time, compare the variable time with the timer. When the timer value is greater than the maximum value time, it means the player exceeds the maximum time, and the decision system will stop working. 

Scoring system:

  • Action correct, earn one point: When the player's action is correct, score increases by 1, and CyberPi's LEDs light up green.

  • Display next command and turn off LEDs: When the player's action is correct, CyberPi displays the next command. The screen should have been cleared and the LEDs turned off before CyberPi displays the next command.

Action wrong, Game Over:

  • When the player's action is wrong, the game ends. CyberPi will display the score, and its LEDs will light up red.

Results:

  • When the player does a wrong action, the game ends.

  • Make the game more challenging and more interesting.

  • For example, set up the scoring system based on the levels of difficulty. In the harder version, players have less time to react but earn more points for a correct action.

NOTE:

  • The example program provides two levels of difficulty. Build on the example program to diversify the levels of difficulty.

Extension

  • Have students create their own timer by creating a new variable

  • They should use this timer to check wether the player responded within the required time

Wrap Up

Wrap-Up & Quick Check

Objective:

  • Improve students' engagement and encourage them to complete the project by challenging them to the opposite game.

Procedures:

  • Activity 1: Divide students into groups and have them play the game to see which group finishes the most rounds.

  • Activity 2: Invite five to six students to compete in front of the class.

  • Tip: Pick one of the activities according to class performance. To ensure fair competition, invite other students to examine the players' programs.

Downloadable Material

Example Program

Educational Standards

CSTA

CSTA

  • 2-AP-11: Create clearly named variables 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.

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 - Technology & 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. 

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.