RFNXVfwQQPS4J

Mouse in the maze

Source: licencja: CC 0.

Mysz w labiryncie

You will learn
  • how to create a simple board game.

R1S7S4Mfvlcaa1
nagranie abstraktu

Certainly you know computer games, in which the protagonistprotagonistprotagonist walks around the mazemazemaze and collects various items or avoids contact with them. Your task is to create a simple version of such a game.

Think about who may be the protagonist of your game, how the boardboardboard should look, how characters should move, what rules will apply to it.

Before you start to implement the scenario of your game, do the following exercises. These exercises show what solutions you can use in your game.

The sprite touches other objects

Task 1
Rz6S4MLNmFGs81
nagranie abstraktu

Build a script in which the sprite‑cat meets on his way an apple, and after touching it, he says something and then goes backwards.

Use the block touching ... colour from the Sensing category and the conditional expression if ... then from the Control category.

Hint
Ro9sqHRsByPy91
nagranie abstraktu

To change the colour in the block touching ... colour, click the left mouse button on the colour box in the block. After clicking, the mouse pointer will change its appearance. Move the pointer to another object on the screen in the colour you need. When you click again on this object, the colour box in the block will change colour accordingly.

Controlling the sprite movement

Task 2
R14RuMkEZyXrz1
nagranie abstraktu

You want the direction of the sprite movement to be changed using the arrows.

Build a script in which pressing the arrow will cause the sprite to turn in the desired direction.

Game board

R1e5B4MdIaAcq1
nagranie abstraktu

To create a game boardboardboard containing a mazemazemaze, you can create it from scratch in any graphic editor (remember that the Scratch scene is 480 points wide and 360 points high). You can also modify one of the backdrops from the program library called xy‑grid‑30px or use the following board.

R1NHl63OQJxSK
Source: GroMar Sp. z o.o., licencja: CC BY 3.0.
RZOMpW0j56Cy41
Source: GroMar, licencja: CC BY 3.0.
R17W6u6HmkMr01
nagranie abstraktu

Mouse in the maze

You already have a board ready. Now it's time to place sprites on it.

Task 3
R7nIOtvLPeJ1S1
nagranie abstraktu

Place two sprites on the board. Adjust their sizes to fit entirely in a single mazemazemaze field. Choose the coordinates of the position of the sprites so that after the green flag lights up they are always in the same place.

Hint
R1NJvayunAHib1
nagranie abstraktu

Use the block set size to ... % from the Look category.

Task 4
R4GzyNWQq0QX51
nagranie abstraktu

Choose the number of steps of one of the sprites, so that after pressing the space it would go entirely to the next field, and pressing the arrow would change the directiondirectiondirection of its movement. The second sprite remains still all the time.

If the sprite touches the field beyond the mazemazemaze path, it should go back to the previous position.

Hint
RfPg9DeUQ8cad1
nagranie abstraktu

Use the solution for the command from the beginning of the lesson.

RarwNOwGBbB451
nagranie abstraktu

Introducing action to the game

Your sprite can move around the maze. Think about what should happen to the sprites in the moment they meet.

Remember to save individual stages of your game under various names, e.g. Maze_version1. This way it will be easier for you to make changes or go back to successful solutions.

Task 5
R10XLxjTllM4f1
nagranie abstraktu

Modify the previous script so that the sprite wandering around the mazemazemaze „eats” the second sprite.

Hint
RP67aagyQF0kz1
nagranie abstraktu

When the wandering sprite meets another sprite, he broadcasts a message to him. The second sprite, after receiving the message, executes a given command. You will find the blocks you need in the Events category.

R7bPTexaNLYFC1
nagranie abstraktu

The second sprite receives the message and executes the command:

R1GjiMCeCXZHc1
Source: GroMar, licencja: CC BY 3.0.
RJRaL8ds94bUk1
nagranie abstraktu

Lives counter

No game can go without a scorescorescore or lives counterlives counterlives counter. To add counters to the game, create a new variablevariablevariable in the Data category. We use this variable later to count the scored points or lost lives of the protagonistprotagonistprotagonist of the game. After creating the variable, new blocks automatically appear, which we use to build scripts.

Task 6
R1QZpme9WqmBF1
nagranie abstraktu

In the Data category, create a new Lives variable. Look what new blocks appeared. Consider how to modify your codecodecode so that the sprite will lose one life after accidentally touching the wall of the maze. When the number of lives is exhausted, the game ends.

Hint
R1QreAOmeIvUk1
nagranie abstraktu

If you are not sure how to apply the newly created variable in the codecodecode, look at the following slideshow.

Rh6fUkBHEXvNp1
Prezentacja multimedialna - licznik. Instrukcja obsługi z poziomu klawiatury: 1. Uruchomienie aplikacji - ENTER, 2. Na każdym ze slajdów czytany jest automatycznie tekst alternatywny po polsku, 3. Przy pierwszym uruchomieniu na pierwszym slajdzie, czytanie tekstu po angielsku - TAB, 4. Przejście między slajdami: do następnego slajdu - TAB, do poprzedniego slajdu - TAB + SHIFT, 5. Przejście do czytania napisu po angielsku - strzałka w górę + strzałka w dół (czyta tekst po angielsku widoczny na slajdzie).
Source: GroMar, licencja: CC BY 3.0.
R1AOFMdB5roWQ1
nagranie abstraktu

In Scratch you can define new variables. Sprites can communicate with each other.

Exercises

Exercise 1
R1U15cE807EOr
Wersja alternatywna ćwiczenia: Determine which sentences are true. Możliwe odpowiedzi: 1. By creating variables, you decide whether only the scripts of the chosen sprite or all scripts have access to a given variable., 2. The stage is 480 points high and 360 points wide., 3. Blocks starting with a word “if” are conditional statements., 4. You can duplicate the spirits' costumes, but you cannot duplicate the backdrops.
zadanie
Source: GroMar, licencja: CC BY 3.0.
Exercise 2
Zastanów się jaki powinien być kod, aby po duszek po zjedzeniu innego duszka przechodził na do kolejnego labiryntu.
Zastanów się jaki powinien być kod, aby po duszek po zjedzeniu innego duszka przechodził na do kolejnego labiryntu.
Exercise 3

Explain in English what commands should be entered into the code so that the sprites communicate with each other.

Exercise 4
RLl5mjpllx90f
Wersja alternatywna ćwiczenia: Indicate which pairs of expressions or words are translated correctly. Możliwe odpowiedzi: 1. zmienna - variable, 2. bohater - protagonist, 3. labirynt - maze, 4. plansza - board, 5. kierunek - lives counter, 6. licznik żyć - direction
zadanie
Source: GroMar, licencja: CC BY 3.0.
R1amUnrSxSKUN1
Interaktywna gra, polegająca na łączeniu wyrazów w pary w ciągu jednej minuty. Czas zaczyna upływać wraz z rozpoczęciem gry. Jeden ruch to odkrywanie najpierw jednej potem drugiej karty z wyrazem. Każdy wyraz jest odczytywany. Kolejny ruch to odkrywanie trzeciej i czwartej karty. W ten sposób odsłuchasz wszystkie wyrazy. Nawigacja z poziomu klawiatury za pomocą strzałek, odsłuchiwanie wyrazów enterem lub spacją. Znajdź wszystkie pary wyrazów.
Source: Zespół autorski Politechniki Łódzkiej, licencja: CC BY 3.0.

Glossary

board
board

plansza

RVN3k5D1uV1GA1
wymowa w języku angielskim: board
code
code

kod

R1JorZ2D5ClUr1
wymowa w języku angielskim: code
direction
direction

kierunek

RpSOosSa5kz4D1
wymowa w języku angielskim: direction
lives counter
lives counter

licznik żyć

R12hUdtcuotHC1
wymowa w języku angielskim: lives counter
maze
maze

labirynt

RAimwz0RRxXKe1
wymowa w języku angielskim: maze
protagonist
protagonist

bohater

Ra8hm6Q07yqxi1
wymowa w języku angielskim: protagonist
score
score

punkt

R1Czzukv0Kyw11
wymowa w języku angielskim: score
variable
variable

zmienna

RCBeE3UIqQDMk1
wymowa w języku angielskim: variable

Keywords

boardboardboard

lives counterlives counterlives counter

mazemazemaze

protagonistprotagonistprotagonist

variablevariablevariable