4. Hello World

Hello World

“Hello World” is the first sentence of any robot. During this session we ensure that we can also talk to our computer. As always, you can use your own creativity and you should not just imitate everything that we show here. What you should do is use more programming language, because that's the only way to learn!

You learn to:

  • ask a question to the user
  • use the user's response
  • put pieces of text together
  • change playing field / background during the game

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?

Answer the questions of the fish.

PREPARATION

Take a look at 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

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

STEP 1

Go to the online editor in Scratch. Choose a backdrop and a sprite. You still know how to do this from previous activity. You remove the cat again. We choose an underwater environment and as a sprite we choose a… grumpy fish! (It all has to remain a bit credible of course!)

1

You can of course also take 2 sprites! Start with one and if it's all a bit too simple for you, you can add a second one.

STEP 2

We want to engage in a conversation with our fish. Select your sprite and come up with a question the sprite can ask you. Feel free to make it funny!

To ask a question you can use the following block:

2

You can find this block in the group "sensing". After that, the player will enter an answer to which the sprite will respond. Can you program the correct code?

Would you like to test whether everything is correct in terms of content?

STEP 3

Your audience will quickly realize that your sprite keeps saying the same thing no matter what is answered. Delete the code you created in step 2. We will now make another code: we will use your player's answer in your sprite's answer.

Use the question "Blub, what's your name?". The answer should be "[player answer] is not a fish name!" You can find the answer of the player by using the following block:

4

If you want to combine the answer with another piece of text, you can merge them with the following block:

5

toelichting

You will notice that the answer and your sentence stick together, you can avoid that by starting your answer (here: “is not a fishy name”) with a space.

uitdaging

a) Now build up the conversation with your Sprite!
b) Can you turn your answer into a variable? You can then reuse it several times.

STEP 4

Now we're going to code your sprite to do something specific depending on your answer. Come up with a closed question. That is a question to which your player can only answer "yes" or "no". Now build up the conversation. If your player answers "yes", your sprite will move to the next step, otherwise not.

Is it not working? Make sure you don't have too many spaces.

However, if your player's answer is "No", your sprite will answer nothing. How can you make the sprite say "Oops, get out!", By changing just 1 block and adding 1 block?

You will now notice that it is not important what your answer is, as long as it is not "yes".

STEP 5

You can also change the appearance. Click on the "costumes" tablet and see how many variants of your sprite are already there.

9

Is there only one? Then you can create one yourself (duplicate) like we did.

10

Try the drawing material that you see on the right side. This way you can make the fish look even crazier!

11

We let the sprite change its appearance ("costume") if the answer is yes. Do you know how to do this? You only need to add one block to the existing code.

STEP 6

We can have the sprite ask if you want to go with him to another place. If your answer is 'yes' then you need to change the backdrop. For this you will first have to insert different backdrops.

You can program the code yourself without hint!

63

Can you make your sprite move too? For example: if you indicate that you do not like fishing, the fish will swim away ...

REFLECTION

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