Mash Club - Coding and Blogging - Session 3
Transcript of Mash Club - Coding and Blogging - Session 3
2 Mash Club - Coding and Blogging - Session 3
Tel: 0208 203 1781 | Email: [email protected] | Twitter: @2simplesoftware
1 Session 3
1. Open 2Code Gorilla and view. Drag in a character . Change the image
property, by double-clicking on the character, to the robot below who you will find it in the robots
category of the clipart picker. Add a disco background :
3Session 3
Need more support? Contact us: Tel: 0208 203 1781 | Email: [email protected] | Twitter: @2simplesoftware
2. Change his name to Elvis (or your choice of name).
Save: Now that you've designed your screen, save your work so that you don't lose it.
Click on the save button at the top and give your game a name, maybe 'Robot Fun'?
3. Exit design view and drag the block into the coding window and select Elvis
as the clicked object.
4. Drag inside the block and make him say something when he is
clicked on using the code below:
Save and test your program.
5. Now you are going to add a button that will make him dance. So go back to design view and drag in a
4 Mash Club - Coding and Blogging - Session 3
Tel: 0208 203 1781 | Email: [email protected] | Twitter: @2simplesoftware
object. Name it 'dance'. Double click on the button and type text such as 'Make me
dance!'.
6. Explore the other properties of the text object, you can make the colour of the button, text and
border how you want by altering these properties.
7. Set the to 'hide'. This will mean that when the program first starts, you can't see
the button.
8. Exit design mode and add the line of code below that will make the button appear after Elvis has
spoken
5Session 3
Need more support? Contact us: Tel: 0208 203 1781 | Email: [email protected] | Twitter: @2simplesoftware
Save and test your program; does the button do what it is supposed to?
9. Next, Elvis needs some music to dance to when the button is clicked. Drag in a new
block, this time for 'dance'. Drag in a 'sound' block.
10.If you click on the button, the sound picker will open.
11.In the Music section is a clip of dance music. You could also experiment with playing your own tune
6 Mash Club - Coding and Blogging - Session 3
Tel: 0208 203 1781 | Email: [email protected] | Twitter: @2simplesoftware
using the electric piano or the guitar. The final choice is to upload an mp3 file from your device.
12.So far the tune will only play once, make it repeat forever by changing the code
13.Well now he's got some music, let's make him move a bit! Add a inside the when
clicked dance block to repeat every 2 seconds that makes him move up.
7Session 3
Need more support? Contact us: Tel: 0208 203 1781 | Email: [email protected] | Twitter: @2simplesoftware
Save and test your program; does Elvis go up?
14. He looks more like he's blasting off than dancing so this still needs some work. You are going
to be adding a timer inside the first timer so that after half a second (0.5 seconds) of moving up,
he will start going down again. Look carefully at this code to see what it should look like.
Especially pay attention to where the timer says and where it says .
Try to have a think and understand the difference between the use of and
in timers, this is a place where people often end up with bugs so it's important to understand
the difference between the two. The code says Elvis should start moving up every 2 seconds, after 0.5
seconds he should go down. It's quite tricky to get the timing right on this. If you test your code now,
you will find that Elvis moves down more than up so he gradually moves off the screen which isn't
correct but we are going to be adding some more dance moves so it's ok to leave it for now.
8 Mash Club - Coding and Blogging - Session 3
Tel: 0208 203 1781 | Email: [email protected] | Twitter: @2simplesoftware
Save your program.
15. Let's make him look like his body is moving. After he starts moving down make his image change to a
different robot image .
16.To finish the dance, add two more timers inside the ones that you have already. After 1 second Elvis
image should change to and he should move right and after 1.5 seconds his image
should change to and he should go left.
9Session 3
Need more support? Contact us: Tel: 0208 203 1781 | Email: [email protected] | Twitter: @2simplesoftware
Save and Have you got Elvis dancing? Does he stay pretty much in the same
place without moving off the screen now?
Look at the timer. It runs every 2 seconds and the different moves each run for 0.5
10 Mash Club - Coding and Blogging - Session 3
Tel: 0208 203 1781 | Email: [email protected] | Twitter: @2simplesoftware
seconds so the four 0.5 seconds add up to 2 seconds, this is why he doesn't move off the screen like he
was doing before.
17.If you find he is still moving off the dancefloor, you could add the following code at the end of
the program to reset his position every 30 seconds:
Challenges
Challenge 1 Can you add some more dance moves and maybe add a restart button?
Challenge 2 Try adding some more tunes, perhaps with a different button for each tune and change
the dance moves to fit the tune that the player selects.
Challenge 2 You could add another dancer. In the clipart picker, there is a 'boy dancer' and a 'girl
dancer' category or try painting your own dancers.