The Frog Maze
The Frog Maze
The Frog Maze
PROGRAMMING
THE FROG MAZE
Slides by
Ms. Abeera Sikandar
lecturer
bahria college anchorage
computer sciences
Sprite: Frog and Gift box
Backdrop: night-time class
Starting values
Click on the frog. Set the starting position and size of frog sprite.
Forever Loop
We want the frog to move not just once but again and again, so we
need to put the movement blocks inside a forever loop.
The Gift
Then add a forever loop, to make snake move forward and backward.
The rotation block means the snake stays facing the right way.
Add a Conditional Loop
As the snake will touch the frog, the game will stop.
For this, Put the ‘touching Frog’ inside the conditional loop block.
If frog touches the gift, he wins. So the loop used here will be:
Conditional loop
Click ‘Sound’.
What is a module?
The module is like a mini-program that stores commands to make
the script smaller and easier to read. The module has a name
chosen by programmer.
They are also called procedures/functions.
A programmer can use modules in their programs. When the computer sees the name of a
module in the program, it will carry out all the commands stored in the module.
Frog script:
Load the maze backdrop. Put the frog in its right place.
Movement module:
Change all movement modules from 10 to 2. This will let the frog
Move slowly and easier to control.
Edit the scripts
Edit means making changes to your script and make new script.
Gift script:
Set the x/y coordinates of gift sprite and set it at the end of maze.
Go back to start:
Sense block will be in if structure.
If frog senses maze walls, it will go back to its start position.