"> ");

Automatic Random Motion of an Enemy Character

Automatic Random Motion of an Enemy Character


Video – Automatic Random Motion of an Enemy Character


#accordions-601{display: none;}
#accordions-601 {
text-align: left;
background: url() repeat scroll 0 0;
padding: 0;
#accordions-601 .accordions-head{
background:rgba(112,176,255, 1) none repeat scroll 0 0;
#accordions-601 .accordions-head-title{
#accordions-601 .accordions-head-title-toogle{
#accordions-601 .accordions-head:hover .accordions-head-title{
#accordions-601 .ui-state-active{
background: #4b8fe3;
#accordions-601 .accordion-content{
background:rgba(255,255,255,1) none repeat scroll 0 0;
#accordions-601 .accordion-icons{
#accordions-601 .accordions-head:hover .accordion-icons{
#accordions-601 .accordions-head{}
#accordions-601 .accordion-content{}

Video Transcript

Good evening!

The game “banana hunt” seems very interesting to me. I’m looking forward to finish, so I can play it, too.

In this lesson, which consists of 2 parts, great progress will be made.

New characters will be embedded in the game and you will program their behavior.

Stevie you are on!


Thank you Athena!

I’m glad you find the game interesting. You will definitely be one of the first to try it out. I promise!

Good evening!

We have left a task in the middle. In today’s lesson, we will continue to create “Banana Hunt” even further.

Before we continue, we need to remember what we have done so far.

I have prepared videos that you will watch at fast forward that will help you remember where we are.

Let’s watch it …

I have many things to show you today so I should get into the screen.

I need a way to get into the screen please .. (finger clapping ..)

To begin with, we should make the monkey a little bit smaller.

I think it’s too big and it will make it hard for us to play this game.

We want to see the new size from the beginning of the game and throughout its whole duration.

So we want the size of the monkey to be much smaller by clicking on the green flag when the game starts.

From the “Looks” command palette, locate the command block “set size to 75%”.

Drag the instruction to the script area and apply it directly under the command “When the green flag is clicked”.

I recommend that you change it from 75% to 30%.

Try the script after the new change ..

Very nice. The next step will be to change the stage.

Let’s get rid of this boring white by choosing a background from the scratch library.

This is the area of the software that manages the backgrounds.

Let me push this button that will take me to the scratch library.

Select the “woods” backdrop and click OK.

Very nice! Our game has already the desired shape.

It is time to deal with the rest of the sprites. Let’s start with the lions. It is important to note that each lion moves differently.

To add another item from the Scratch library, follow the procedure that we followed with the monkey.

This time select the Lion sprite. Quite large. Let me make sure it is smaller when the game starts.

I will follow the same procedure I just followed with the monkey.

When the green flag is clicked then

“Set size to 50%”

Let’s give motion now to the lion. We will of course use the Command palette “Motion”.

I will first select the ‘move 10 steps’ instruction.

Let me put it in my script and press of the green flag.

You have surely noticed that the lion barely moved.

If this command enters a block repeat forever, once this little move has finished it will do it again and again.

This way it will move continuously throughout the game, and the movement will look contiguous. Let’s try it ..

The lion reaches the boundaries of the setting where it necessarily stops.

It is a good idea to set the lion to continue its move after finding the edge of the stage, making a gel on it.

This feature is provided by scratch with the command “If on edge bounce”.

Let’s put it in our scenario, and let’s run the script.

The new problem that we have to solve now is to set the object’s orientation after the bounce as it is upside down.

To correct this problem we need to change the sprite’s rotation axis. This is done by its attributes.

Let’s set the axis of rotation horizontally and run our program again.

Much better! But the lion’s movement is horizontal, so it covers a small area of the


If the lion started from a diagonal position would cover most of the stage. I will set it off from a corner.

From the “Motion” palette, I will incorporate at the beginning of my script the sprite’s turn.

Let me try my script now …

Perfect … I think we have made significant progress.