Lesson 8 - A Running Moth
Lesson 8 - A Running Moth
A Running Moth
Duration: 45 minutes
Objectives
By the end of class, students will be able to…
● create a program that combines multiple conditional statements to create an interactive program in
mBlock;
● change the direction of a sprite;
● describe the two ways to detect keyboard input from a user;
● program a game to end based on a specified condition.
Overview
By combining previously learned skills, students create an interactive game where the moth tries to avoid
being eaten by the bat. Students program the moth to move using multiple conditional statements that
detect when the arrow keys are pressed. Students program the game to end and stop all scripts using a
conditional statement that detects if the bat and moth are touching.
Key Focus
● Use simultaneous conditional statements to create an interactive game.
Pre-lesson Checklist
For Teacher:
● A computer with mBlock software installed or access to the mBlock software website
● Slides Presentation: Lesson 8 – A Running Moth - Visual
For Student:
● A computer with mBlock software installed or access to the mBlock software website
Standards
© education.makeblock.com
1
● CSTA 2-AP-13: Decompose problems and subproblems into parts to facilitate the design,
implementation, and review of programs.
● ISTE-1D: Students understand the fundamental concepts of technology operations, demonstrate
the ability to choose, use and troubleshoot current technologies and are able to transfer their
knowledge to explore emerging technologies.
● ISTE-5C: Students break problems into component parts, extract key information, and develop
descriptive models to understand complex systems or facilitate problem-solving.
● ISTE-6A: Students choose the appropriate platforms and tools for meeting the desired objectives
of their creation or communication.
● ISTE-6B: Students create original works or responsibly repurpose or remix digital resources into
new creations.
● ISTE-6D: Students publish or present content that customizes the message and medium for their
intended audiences.
© education.makeblock.com
2
Lesson Plan
Warm-Up [5 min]
In the previous lesson, we travelled around the world with Panda. Look at the following program, do
you remember how this program works?
Program Description
While traveling, Panda learned about many of the animals that live on Earth. While sleeping under the
stairs on a camping trip, Panda observed a bat chasing a moth. The moth was trying very hard to
avoid the bat, but eventually the bat would catch the moth. Let’s help Panda create a program that can
reenact this scene.
© education.makeblock.com
3
Explore a mBlock Project – A Running Moth
Instruct the students to open the example, A Running Moth. Allow students time to play the game and
explore the program. The player controls the moth and runs away from the bat so that it is not eaten.
Use the arrow keys on the keyboard to control the movement of the moth. If the moth touches the bat,
it will fall down from the air and the game will be over.
In Lesson 3 – Talented Transformations, we used Event blocks to use the arrow keys to control a
sprite. In this lesson, we will learn another way to control a sprite using the arrow keys. This lesson will
the following conditional statements instead of Event blocks:
The block moves a sprite in the direction the sprite is facing. In order to change the
direction a sprite moves, you must program the sprite to point in your desired direction.
© education.makeblock.com
4
Block
Block Function Example
Area
Sensing Blocks
Instruct the students to write their program according to the steps below:
1 Create a new mBlock project. Find and select the appropriate blocks from the Block Area to create
the following program.
© education.makeblock.com
5
2 Click the in the Stage Area to run the program. Press the up arrow to observe Panda moving
up.
3 Find and select the appropriate blocks from the Block Area to create the following program.
4 Add conditional statements for the left arrow and the right arrow keys.
5 Click the in the Stage Area to run the program. Press the up arrow to observe Panda moving
in four directions: up, down, left and right.
© education.makeblock.com
6
Block
Block Function Example
Area
Instruct the students to write their program according to the steps below:
3. Click the in the Stage Area to run the program and observe the opponent sprite moving
around the stage.
4. Find and select the appropriate blocks from the Block Area to create the following program to stop
all of the scripts in the program and end the game.
© education.makeblock.com
7
5. Click the in the Stage Area to run the program. Move the Panda to touch the opponent sprite
and observe the program stop.
2. Set starting positions for both sprites using programming blocks when the green flag is clicked.
4. Program the bat to fly around the stage after waiting one second to allow the playter time to get
ready.
6. End the game and stop all the scripts when the sprites are touching.
Extension Activity
Challenge students with remaining time to do one or more of the following:
● Program the moth to fall and hide when it touches the bat.
© education.makeblock.com
8
● Change the transformation effect of the moth when it touches bat. Be sure to reset the
appearance effect of the moth at the start of the program.
© education.makeblock.com
9
Wrap-Up [5 min]
Quiz
1. From the following options, which block can stop the action of all sprites?
Answer: A
2. Which block combination is used to animate the effect that the character is falling down from
the air?
A. B. C. D.
Answer: B
A. a
B. b
C. c
D. d
Answer: A
© education.makeblock.com
10
4. Pressing ____ key can realize the effect of “Stop all” running programs immediately.
© education.makeblock.com
11