0% found this document useful (0 votes)
9 views11 pages

Lesson 8 - A Running Moth

Uploaded by

naicker.e
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views11 pages

Lesson 8 - A Running Moth

Uploaded by

naicker.e
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Lesson 8

A Running Moth

Subject: Computer Science

Level of Difficulty: Intermediate

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

Click the green flag, the sprite appears on the


stage area; When the mouse pointer touches the
character, it disappears.

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.

Game Time [5 min]


Instruct the students to open the example program, 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.

How long can you stay alive?

© 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.

How long can you stay alive?

Hands-On [20 min]

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:

1. IF the ↑ up arrow key is pressed, THEN the sprite moves up.


2. IF the ↓ down arrow key is pressed, THEN the sprite moves down.
3. IF the ← left arrow key is pressed, THEN the sprite moves left.
4. IF the→ right arrow key is pressed, THEN the sprite moves right.
5. IF the Panda touches the opponent, THEN the game is over / stop all scripts.

Changing the Direction of a Sprite

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

Specify the direction the


sprite faces. Adjust the
direction using the diagram
or by inputting a value.
0 Up
90 Right
180 Down
-90 Left

Sensing Blocks

In Lesson 7, we used the block from the Block Area to determine


whether the sprite was touching the mouse pointer or the edge of the stage. We will use the following
Sensing block to detect when a key is pressed.

Blocks Area Block Function

Sensing block used in a


conditional statement to
1 determine if a condition is met.

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.

Stop All Scripts


Now that Panda is able to move around the stage using keyboard input, we need to create an
opponent for Panda to avoid. We will add another sprite, program it to move around the screen and
program it to stop the entire program if it touches Panda.

© education.makeblock.com
6
Block
Block Function Example
Area

Stop all scripts of the program.

Instruct the students to write their program according to the steps below:

1. Add another sprite of your choosing to your program.


2. Find and select the appropriate blocks from the Block Area to create the following program.

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.

Try It [10 min]


Independent Practice
Instruct the students to create the Running Moth game. Their final project should do the following:
1. Contain two sprites, “Bug2” and “Bat1”, and an appropriate background.

2. Set starting positions for both sprites using programming blocks when the green flag is clicked.

3. Program the moth to move using the arrow keys.

4. Program the bat to fly around the stage after waiting one second to allow the playter time to get
ready.

5. Create an animation of the wings flapping on the bat.

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.

● Add Panda to the program to watch the moth and bat.

© 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

3. When pressing key “C”, what will the character say?

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.

Answer: Right arrow (→)

© education.makeblock.com
11

You might also like