The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1

(^84) THE OFFICIAL RASPBERRY PI BEGINNER'S GUIDE
when left arrow key pressed
switch costume to left
turn^15 degrees
when right arrow key pressed
switch costume to right
turn^15 degrees
when up arrow key pressed
move 10 steps
when down arrow key pressed
move -10 steps
when clicked
gotox:^0 y:^0
pointindirection^90
repeat^6
turn^60 degrees
create cloneof myself
when clicked
forever
playsound dance around untildone
Finally, you can simulate a full dancing routine by adding a new event trigger to your
program. Add a when space key pressed Events block, then a switch costume to right
block. Underneath this, add a repeat 36 block – remembering to change the value from the
default – and inside this a turn  10 degrees block and a move 10 steps block.

Free download pdf