Thursday, October 19, 2017

Report cat and mouse game Felice and Eiffler

(banner que diga ¨cat and mouse game¨)

In this post, we are going to explain you how we made our ¨cat and mouse game¨ work. We used the programme "Scratch", in which you have to combine different blocks to make objects and other things respond to your actions.

We had to create the game using these 10 blocks obligatory:


This is how the game works:



The game starts when you click on the green flag. There is a mouse, which which goal is to eat the cheese, and a cat. The player controls the mouse, and to win, the mouse has to eat the cheese. But there are two obstacles: the mouse has to threw to a maze without touching the walls to reach the cheese, and the cat is moving the whole time, trying to catch the mouse. If the cat touches the mouse, the player will loose the game.

The maze:
We created this maze by painting blue and black lines on a white background.

How the mouse moves:

The mouse (animal) follows the mouse pointer forever, which is why we didn´t have to put a ¨move ... steps¨ for it to move. Although, we used this block to make that if the mouse distance to the mouse pointer is less than 3, it should only move 4 steps. We created this because otherwise the mouse (animal) would go crazy every time he was too near the mouse pointer.

The mouse around the maze:


When the game starts (so, when you click on the green flag) the mouse always goes to the same position (x: -216 y: -96). After that, if it touches a wall, it goes to that same position again. The maze walls are blue and black, so all we had to do was putting that if the mouse is touching the blue or the black color, it has to go to the position x: -216 y: -96. The ¨forever¨ block is so that this happens threw the whole game.

The cat

The programes above are the ones used for the cat to move. When the green flag is pressed, the cat goes to a specific position and points in direction 90 (to the right). Then, forever, the cat moves 5 steps. There are 2 sets of blocks that make that the cat repeats the ¨move 5 steps¨ action until it touches the color black or blue (the walls).
Going back to the other set of blocks (the longest one in the picture)... What it does is that if the color pink (we painted the cat´s nose pink) is touching the color blue, the cat should turn. Scratch randomly chooses if the car should move 90, 180 or 270 degrees (it chooses 1 to 3 and then multiplies it by 90). This part of the set of blocks is twice, once for the blue color and the other for the black color. We did this so the cat could move around the maze without going threw the walls (it turns instead).
We also combined two other blocks (not shown in the picture) that make that the cat bounces every time it is on the edge. (Blocks ¨when green flag pressed¨ " + ¨if on edge, bounce¨.)

The cheese:


The cheese is always in the same position, at the end of the maze (x: 180 y: -113). When the green flag is clicked, it is shown on the screen. But, if it is touching ¨Sprite1¨ (the mouse) it hides forever, until you press the green flag again. When the cheese hides, it also sets a variable called ¨Finish¨ to 2. We will now explain how this works.

Variable Finish:


We created a variable called Finish, that the player can´t see on his screen. We created it so the game finishes once the mouse ate the cheese (you win) or the cat ¨catches¨ the mouse (you lose). The programes above are for the cat object. When you click on the green flag, this variable sets to 0. Then, if finish equals 0 and the cat is touching Sprite1 (the mouse), the variable finish is set to 1. We combined the blocks so that if finish equals 1, then the cat will say ¨You lose!¨ for 2 seconds and all the programes of the game will stop.
In the mouse object we did this:


As we showed you before, when the cheese hides it sets the variable Finish to 2. In the mouse object, we created a program that makes that if ¨Finish¨ equals 2, the mouse will say ¨I win!¨ for 2 seconds. In this case, the programes of the game won´t stop, so you can still move the mouse and the cat will also keep moving.

Sizes:
A problem we had was that the objects (the mouse, the cat and the cheese) were to big for the maze. This was easy to solve. In each program, we combined three blocks (you can see them in the picture above) that set the size of the object to ...%. The cheese, for example, was very big, so we had to set its size to only 25%.

                                    


No comments:

Post a Comment