We try to get the cat to the exit of the maze, but we soon run into a problem. Most likely, all the passageways are blocked and turn out to be dead ends. There is no way to reach the exit, because the cat can't move through walls.
How could we solve this issue? Let's make holes in the walls. We will add a bomb item that the player can use to blast holes in the walls. That way, they can always reach the exit.
We draw another new sprite that resembles a classic cartoon-style bomb with a sparkly fuse. It's easier to draw the item a bit bigger than is needed and later, scale it down with a script.
This drawing can be made with the Scratch drawing tool, by performing the following steps:
The following is a nice looking bomb in just a few steps:
We also need a way to make the holes in the walls. Since those are stamped onto the stage, we can't really remove any elements. They are just a drawing on the canvas. What we can do is stamp over them with white. For this, we create another sprite to use as a stamp. In this case, it is important that the sprite is exactly of the right size, so it will fit the maze segments.
We can create this sprite in an external image editor as we did for the tiles. What we need is the four-way crossroad tile without the black corners (tile11
). We can easily copy and adapt this tile.
If we need to draw the tile with Scratch, we can follow the same procedure as described earlier for drawing the tiles:
It might be easier to first fill the entire space with white and then draw invisible squares in the corners using the transparent color.
Once our hole stamp is done, we can start scripting. Let's not forget to name the bomb sprite as bomb
and the hole stamp as hole
.
Let's first write the scripts to place the bomb:
I used 50
for the value, but if your sprite was drawn bigger or smaller, you might need another value. Just experiment until the bomb fits the maze.
Then, we add another keyboard control to place a bomb using the following steps:
At this point, we need another message for the explosion event. For this, perform the following steps:
The next step is to create scripts for the hole
sprite. This will mainly respond to the createHole message we just added. Perform the following steps:
If placed correctly, the bomb item should now blow holes into the black walls. Once the walls are removed, the cat is free to move on.
We just created a sprite item to be used by the player and a functional effect to make the item work. Stamping over the stage can be an easy and effective way to change the level design. It can be used as a player instrument, as in this case. However, you could also use it for automated changes and challenges in the game, such as opening and closing doors and throwing temporary hazardous effects into the level.
18.216.96.94