This is a maze game, so the goal is to reach the final position at the top of the screen. To do this, move the cat sprite using the keyboard arrows. But be careful, you must not touch the walls of the labyrinth!
To program this game, we will use the Scratch software which has the advantage of using visual code: no need to learn a programming language. programming to build games.
Access the site http://www.mazegenerator.net/ to automatically generate the maze.
1) Go to import a background to add the image of the generated mazes.
2) We get a background that contains mazes:
The game starts when the green flag is clicked to place the cat sprite at the start of the maze.
We insert the blocks necessary to move the cat sprite via the keyboard arrows:
When the right arrow is pressed the cat sprite should orient and move right.
When the left arrow is pressed the cat sprite should orient and move left.
When the up arrow is pressed the cat sprite should orient and move up.
When the down arrow is pressed the cat sprite should orient and move down.
To prevent the cat from crossing the maze walls, one must use the block from the Sensors category which checks if the cat is touching the wall color.
To punish the player for touching a wall, the cat is placed in the initial position.
To check if the cat is touching the wall, we must use the If then else block.
If the condition (the black color is touched is true), the cat is placed in the initial position. And if the condition is false, the cat continues on its way.
Here is the final scratch program of the Labyrinth game:
Download maze game