Creating the Maze

Creating the Maze

 

Part C – First Video


Video Transcript

A very interesting sprite is the ghost.

The ghost of our game will be able to appear in random stages for a few seconds.

In these seconds it will try to catch the dog. If it does, the game will end.

It is therefore an opponent.

Another important detail regarding the behavior of the ghost is that it will be able to pass through walls.

So when we will add the maze we will not have to change this scenario as there is no interaction between them.

Let's add the ghost from the scratch library.

Its size is quite large. I'll cut it down a bit. Let’s say 60%.

I will also change its axis of rotation to horizontal so it never looks upside down.

We will probably need two scenarios running in parallel.

In the first scenario, throughout the game the ghost will chase the dog.

be shown and hidden for a random period of time.

Let me start with the 2nd scenario.

We will definitely need the repeat structure "Forever" as we want the show-hide process to continue throughout the game.

At first we do not want it to appear. From the "looks" instruction palette, use the "hide" instruction.

Then we want it to remain invisible for a random period of time between 5 to 10 seconds.

You need to combine the 'wait' instruction - you will find it in the “control” panel with the scratch instruction that creates random numbers from the palette “operators”.

Very nice.

Once this random time has passed, we want the ghost to move at a random area of our stage and then to appear again.

It is important not to forget to set and then display a random time frame for the ghost to appear until the instructions start running from the beginning.

Let's create the script and try the outcome.

The script works very well. However, when the ghost appears, it remains still.

Also, its contact to the dog does not create any interaction. Let's fix it.

We will create a new scenario. The script will run throughout the game alongside the previous one.

The purpose is to make the sprite always look at the dog and move slowly towards it.

This scenario combines without a problem to the previous one as it does not cancel any of the actions that the previous one performs.

These ghost moves can be done either on the stage or not.

Let me now type the appropriate instructions.

For the duration of the game

Turn to the dog.

Move 1 step.

And if you touch the dog Stop everything!

Let me try it...

It works perfectly. Time to create the maze...


 



 

Part C – Second Video


Video Transcript

So far our game has logic. But it's pretty easy.

Dog movement is not limited at all, so it can easily and quickly reach the bone.

A maze would put obstacles in the dog's movement and would make it difficult for the game.

Let's create a new sprite.

Let's call it a "maze".

I will pick the tool line, and after adjusting the color and width I will begin my painting.

Start from the outer outline.

To plan the interior walls, make sure you have 3 important details

The corridors you create will be large enough to allow both the dog and an identical sprite to pass side-by-side.

Your lines should be parallel and vertical to the walls of the outer outline.

Hold the shift key when you want to achieve this. And use the eraser if necessary in order to erase small projections of the walls that can block the movement.

Let me draw. Music please!

Very nice!

Let me now place this sprite right at the center of the stage..

If I run the script now there will be no interaction between the maze and the dog.

The dog will just run through the walls.

We will change that immediately.

Let's bring on the dog's scenario again.

We want to move the dog - If it touches the maze then the movement is reversed.

The dog's movement is 5 steps, if everytime it touches the maze we have it move 5 steps in the opposite direction, then it will actually remain still.

This is exactly how the maze will work as a wall. Let's now see it in action.

I will try the movement first with the right arrow on the keyboard.

If it touches the maze Move 5 steps backwards.

Let's try it..

Very nice!

I have to add these instructions into the movement the other arrows available to the sprite.