Move the Hero with the Keyboard Arrow Keys

Move the Hero with the Keyboard Arrow Keys

 

Video – Part A First Video


Video Transcript

Good evening!

In this lesson you will watch step-by-step the creation of the electronic game titled: "Grab the bone".

The software to be used is Scratch.

We will connect to Stevie, who is in the countryside along with his dog, to show us all the details and all the steps needed in order to create this game on your computer.

This lesson consists of 5 parts. In each of these 5 parts a detailed presentation of an aspect of the game is presented.

Attention! It is not enough to simply watch this video. You will need most of the videos to watch them over and over again.

So do not worry if you feel the need to do that. You have to do it.

Also make sure your attention is not distracted from the movements of the sprites contained in the videos.

They have been created to make videos more enjoyable but under no circumstances would we want to overcome the content of the video and its educational goals.

Have fun!

 

Good evening!

The game we are about to create in this lesson is called "grab the bone".

It is a game whose stage is a labyrinth as it contains several paths and routes.

A basic first step to start is to watch a few seconds of the game and absorb some information about its basic features and components.

Please have a look at the video and we'll be right back.

All games have a purpose.

The purpose of "grab the bone" is to collect as many bones as possible.

The dog collects bones while trying to avoid fast cars that are trying to hit it, but also the ghost that can appear and disappear at any point of time.

The hero of the game, the dog, is allowed to move in any way in the game labyrinth but can’t touch the cars and the ghost.

If that happens the game ends. This is the only rule of the game.

Basic sprite of the game is the dog.

The dog moves anywhere on the screen the labyrinth allows.

The way the user moves it is with the keys on the keyboard.

The main sprite of our game is bones.

Bones appear randomly in the labyrinth of the game.

Every time the dog touches a bone - it disappears and appears immediately somewhere else in the labyrinth.

At this point the score rises by 1.

Under no circumstances should I forget to mention that the labyrinth is also a sprite.

We could use some labyrinth image as a backdrop, but it would be very difficult to check if a sprite has touched the labyrinth so that we could activate a reaction in this case.

Also another sprite is the GAME OVER message that displays at the end of the game.


 



 

Video – Part A Second Video


Video Transcript

In the game 'Grab the Bone', the dog is moved by the player in the labyrinth with the arrow keys on the keyboard.

Let's start our game by forming this. That is, the scenario that moves our sprite -our protagonist.

As a first step of course you have to start Scratch. Then, you have to delete the cat and enter the dog from the Scratch library.

Let me move on to these actions.

First, I need to change the sprite's size.

So, when the green flag is clicked, the size of the sprite is 25% of its original size.

Then I use the appropriate commands to make the dog look and move upwards if the user pushes the top arrow from the keyboard.

Obviously, we need a selection structure.

From the "control" tab we then need the IF command.

If the up arrow button is pushed then our character should point upwards but also move a little bit forward.

The commands that will be in the IF are in the "motion" command palette.

If a specific key is pressed, we will find it in the “Sensing” palette.

Let's create this IF and let me try it to see if it works.

We see something is wrong.

Our script does not work. The reason is obvious.

The script's instructions are executed one by one and the script ends before we hit the top arrow.

We want this code to run throughout the game.

We have to enter into a repeat order "Forever". Let's do it and let's try again.

Let's do it and let's try again.