Friday, October 20, 2017

Mouse and Cat Game Report Barrera and Poletilo



Dufficulty: Medium






We had to create a report for the second deadline from the third Term of a cat and mouse game, which we did in scratch. In this blog we are going to inform you how we did this work and how to create or complete certain scratch problems. When we started the project we had a list of the blocks we could use. If we weren’t using them it meant we were doing something wrong.






In this game, you are the mouse who has to eat cheese but without getting caught by the cat.

The game begines when you click the green flag and the mouse will start following the mouse pointer. If you want the mouse (animal) to slow down you just have to click on the mouse (control).

The background is a maze with blue walls. When the mouse (animal) touches a wall, it will get back to the starting position. The goal is to eat 10 times the cheese, which will appear in a random position after you ate it. But when the cat caughts you, youl lose. The cat doesn't follow you, it's just roaming around the maze. But be careful, because every time the cat touches a wall, it will change direction and you won't know where to.



This is our maze:



The mouses script:

Firstly, the game had to start once the green flag was pressed. Because we used a speed variable so that the mouse (animal) slows down when you click the mouse (control), we started by setting the speed to 0. We also wanted to make the mouse (animal) always start at the same position and for this we used the motion block "go to x=...and y=..." and to point forwards. If the mouse (animal) touches an edge, it should bounce.



Because we also had different backgrounds, we changed the background to the maze every time you start to play. We also made the mouse (animal) wait for one second because if it would start immediatly after you pressed the green flag it would go towards the flag and might touch a wall.



This is how we made the mouse (animal) move:

Everything after the first things we already explained, we put inside a Forever. This way all the actions will keep repeating until the game finishes.

So that the mouse (animal) follows the mouse pointer, we made the mouse point towards the mouse pointer and move 2 steps. So that the mouse doesn't move like crazy when the mouse pointer is too close, we made the mouse (animal) stop as soon as the mouse pointer is too close. For this we used the If...Then... control with a operator and a sensor. If the distance to the mouse pointer was smaller than 4 pixels, the mouse (animal) should wait until the distance to the mouse pointer is bigger than 4 pixels.

So that the mouse doesn't go too fast, you have the choice to make it slow down by pressing the mouse (control). For this we used a speed variable and set the speed to a slower number.

For the game to be more difficult we made the mouse (animal) go back to the starting position as soon as it touches a wall, but after becaming a cloud of dust because of the crush.




These are some other basic programmings we has to make :






The cats script:


Basic Programming:






This is how we made the cat move:

The cat had to wander around the maze. Every time it crushed against a wall, it had to turn around and choose on it's own if to turn right, left, or go back were it came from. For this, inside a Forever, we put a Control Block: If...Then and inserted a blue colour sensor. So, when the cat touches a wall, it will walk a few steps back, face the way it came from, and pick a random number between 1 and 3 and multiply it by 90. This way, the cat can choose to turn right, left or move forward.
Also, so that the game can end, once the cat touches the mouse, the player loses.




The cheeses script:

The cheese hat to go to a random position, but without touching any blue wall.





These are some images of the game in action








Summarized:





Thanks for reading and we hope it helped you!



No comments:

Post a Comment