Advanced Scratch – Week 5 – Code Recycling and parallel processing

What are we going to learn this week.

  • Buzzer Game – Using old code and a little new code we can build a game.
  • Code recycling – How to re-use code that you have already written.
  • Parrallel vs Sequential Processing – sounds worse than it is 🙂

Buzzer Game

Navigate through the Maze to earn More Money, the more you get the Harder the game becomes.

Most of the code for this game you have already written, cool… But there is some  new code that you will need.

So, lets do the New code first…

We need a coin, or something that you can move with the mouse and that will BUZZ and Shake when it touches a particular colour.

This is my Coin here…

I have one costume for normal and one costume fo buzzing!

We now need to set up some code so that you can move it with the mouse, this is similar code to the button code we did, and I found a better way of doing it!

What you want to happen is if the mouse is on the Coin you can Click to grab it and it will move wherever the mouse moves until you let go of the mouse.

We also want it to Buzz! when it touches a particluar colour, to test this I just drew some lines on the Stage and used the Dropper tool to select the right colour.

SEQUENTIAL PROCESSING – This is my Buzz code, I just move it around a little and make a noise. Notice on the Broadcast that it is a Broadcast and Wait, this allows the Buzz code to work correctly.

 

And the code that allows you to click and drag the coin around the Screen goes something like this…

Advanced Tip 1. To test this piece of code, you will need to run your program in full screen mode, otherwise Scratch is in “design” mode and moves the Sprite anyway.

The Maze.

CODE RECYCLING PART 1. Remember last week whne you did the Truchet Patterns, they were pretty maze like, weren’t they. Well all we need to do is import the Truchet Sprite, maybe play around with it a little bit and you will have your maze.

What I changed in my Truchet Pattern, was the size of the initial square, I made it bigger, and also I didn’t stamp along the top line or the bottom line so the coin has somewhere to aim for.

The other thing that you might have to change is if you have used curved lines, you might want to change them for straight lines, otherwise the gaps between them can be very close. Alternatively you can make your coin very small.

So once I had adjusted my pattern, I ended up getting something like this.

CODE RECYCLING PART 2. Remember the Button we did, well let’s bring that into the Game as well so we can use it to Start everything off

Now you need to connect everything together. This is where the fun Starts…. 🙂

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s