7. Catching butterflies

Catching butterflies

In this game we are going to catch butterflies before they hit the purple line. The butterflies move and come closer and closer. Our safety net cannot pass the purple line, so that will not be a simple game ...

You can certainly use other sprites (eg Aliens and a rocket), which makes your game a lot tougher by the way!

You learn to:

  • send signals from one sprite to the other sprites
  • to use the or block.
  • how to make the image of a sprite have no background.

Register before you start the exercise. Click the button below and sign up.

Click here

ORIENTATION

Take a look at the example and consider the following questions:

  • What should I do?
  • What are the goals?
  • What are the expectations?
  • What can I already do?
  • What do I still have to discover?

Use the spacebar to release a beam from the net to catch the butterflies. With the arrow keys you can move the net from left to right. Note: the purple line is sometimes in the way. If the butterflies hit the purple line before they are caught, you are lost.

PREPARATION

View the steps at 'perform'. Then answer the following questions:

  • Which steps should I follow?
  • Which steps can I follow?
  • How much time do I need?
  • What tools do I need?

PERFORM

Perform the steps one by one. Do you not remember how to do it? View the hints or download the solution.

STEP 1

As usual, open the online Scratch editor and delete the cat sprite. Choose a nice backdrop from the library.

STEP 2

Add two new sprites (eg a butterfly and a butterfly net) and adjust the size. You will have to search for a butterfly net via Google. Then you can upload the sprite to Scratch. Do you make sure that the image has no background? This is nicer, so there is not always a square in front of your background.

Transparant vs niet transparant

The purple dotted line (see example) is also a sprite. You have to draw this yourself. Use straight lines. We will call this sprite 'wall'.

To catch the butterflies, we draw a ray of the net upwards (where the butterflies are). This is also a sprite that you have to draw yourself. Use a thin straight line and use a different color from the purple dotted line.

STEP 3

The safety net must of course be able to move. Select the sprite and then click on 'code'. Can you program the safety net so that it can be moved left and right via the arrow keys, after the green flag is clicked? You learned to build a similar code in the previous exercise.

STEP 4

The idea is that when you press the spacebar, a ray appears from the safety net to the butterfly. The beam then moves upwards. When the beam hits the wall, it should disappear again. The beam should also disappear when it is at the very top.

Now select the sprite of your laser and use the following blocks to make the correct code:

STEP 5

Select the butterfly and make the correct code using the steps. We already gave a small start ...

84

  • The butterfly must always move at a pace of your choice.
  • When the butterfly hits the edge, it should turn 180 ° and get closer to the purple line (y coordinate)
  • When the butterfly is hit by the laser, it says "AU!" and disappears from the game.

If you now click on the green flag, the butterfly will be placed in the right place, it will start to move and it will get closer and closer. Nice!

STEP 6

When the butterfly hits the butterfly net, the game is over. So that all sprites know that the game is over, we will send a signal.

86

You can change the message to 'Game over' by clicking on the arrow and selecting 'new message ...'. Now you can type your own message.

6

You can have the other sprites respond to this message by using the following block:

89

STEP 7

Multiple butterflies can be obtained by copying the sprite of the butterfly twice. You now only have to adjust the starting position of the butterflies. Make sure that the X positions of all butterflies are different so that they line up nicely next to each other. Give the butterflies each a starting x-position of -100, one of 0, and one of 100. If you now click on the green flag, they will be neatly next to each other.

STEP 8

It's still a bit too easy, maybe isn't it? We are going to make the purple line (the wall) move.

First choose the "wall" and enter the following script:

90

The game is playable, but not really “finished” yet. Think about what can be added to the game.

a) What do you want to add?

b) Explain to another Code Classer how you want to build it and discuss together how you can build it the easiest.

c) Build it! Feel free to ask other students, the coaches or the teacher for help.

d) Did it work? Why yes, why not?

REFLECT

Look back at the project you just made. Ask yourself the following questions:

  • Does the program work as I expected? Why / why not?
  • What works well?
  • What works less well?
  • How can I approach it differently?

Download

Click the link below to download a sample solution. 

 

Upload the project in the Scratch environment. Click the button below and follow the steps.

Click here