1 of 13

Computer Science

4.2 Maze Game -Day 2

Continually test condition

2 of 13

Forever Loop has two main uses:

  1. Continually do an action,

……….forever

2. Continually check if a condition is true,

……….forever

How long is forever?

from start to end of a program:

from to

3 of 13

PseudoCode

If touching color green

If touching end Sprite

If Reset

4 of 13

PseudoCode

A. If touching color green

B. If touching end Sprite

C. If Reset

Go to start location

Celebrate!

Say something….

Do something…..

Go to start Location

5 of 13

  1. Condition: True or False?

If touching green wall….

6 of 13

“Touch” is one of our 5 senses,

So touch commands are under Sensing.

7 of 13

How to choose color….

How to choose

color….

Click region on stage with desired color.

(See video).

8 of 13

B. Condition: True or False?

If touching End Sprite….

…..make end level reward(s)

Use Broadcast,

to call multiple things simultaneously:

eg Speak and Dance

9 of 13

Pause: Work on your maze game.

Next slides are related to exit slip.

10 of 13

Learning Objective:

Repeatedly test "conditional statement"

by putting it in a forever loop.

…………..………….but………………...

What is a Conditional Statement?

11 of 13

Conditional Statements:

Conditional Statements evaluate a condition: � if condition is TRUE code does one thing,

if condition is FALSE code does a different thing.

Condition: True or False?

Condition

Path 1

Path 2

next command

12 of 13

Conditional Statements:

Conditions must be evaluated repeatedly incase they change state, not just tested once. To test a condition repeated put into a “Forever Loop”.

Condition: True or False?

13 of 13

Does this code do the same thing?

See example in a scratch project