Creating a Sprite With Painting

Creating a Sprite With Painting

 

Part B First Video


Video Transcript

After the dog, an important sprite is the bone.

Unfortunately, such a picture does not exist in the scratch library.

So we have to create it.

To create your own sprite, start by pushing the brush with "Paint New sprite".

Essentially an empty canvas opens. In this area you can draw your sprite.

First of all, make sure that the bitmap mode is enabled in the bottom right corner

Then, as this is your first contact with scratch painting, take some time and try out the available tools.

Don't rush. There are several possibilities.

It would be best to freeze the video and take some time to experiment.

Let's create the bone. I will need some music please..



 

Part B Second Video


Video Transcript

Now we need to program this sprite in order to appear in random places every time the dog touches it.

This is what we want to do throughout the game, so our instructions will be in a repeating structure "Forever". Of course there is a selection structure as the bone moves only if the dog touches it.

If it touches the dog..

The movement of the sprite now is done with an instruction from the tab "motion".

If I explore my possibilities on this palette I will find the instruction "go to position X and Y".

In our case, we want X and Y to be random and different each time.

Scratch has a process to create random numbers within limits set by the programmer.

From the “Operators” palette, drag into the script area the instruction "pick random 1 to 10".

We will use this instruction to create both the horizontal position of the bone expressed in X and the vertical expressed in Y.

The combination of the two aforementioned instructions will solve my problem.

I will combine them logically and try out the solution.

There it is. Very good!

Let me finish this scenario by entering the variable "score".

I remind you that a variable is a box in the memory of our computer that stores information.

The variable score will count the number of bones our dog eats.

Every time a dog touches a bone, the variable score will store a number 1 greater than what it just was

Of course, at the start of the game the score will be 0.

Go to the "Data" instruction palette and click the button "Create a variable".

The name of our variable is “score” and it applies to all sprites.

Watch how the counter for the variable has already appeared on the top left of the screen.

We want the variable to have a value of 0. This value should rise by 1 as soon as the bone touches the dog.

At this time I will also import a sound from the scratch library.

Once the bone is eaten, the sound is heard. It's an interesting detail in our games.

Let me use the appropriate instructions and try the script.