- In Scratch,
When green flag clickedis used to start and reset games or projects.
- Make your own reset command by using it and attaching the these blocks shown on the right.
go to x:() y:()to reset your robot's position to your starting point.
- Indicate the value in x and y depending on where you want to set the starting point.
Bot Builders : Program Your Robot
Make your robot move
broadcast [message1 v]to trigger a custom event.
- Click on the dropdown icon and select "New Message".
- Make the message, "randomize".
- This will be used to send a message to all the other sprites to move to a random position.
- Now, add
foreverfor the main loop of your robot's code.
- Add four
if <> thenblocks for each direction your robot will walk.
key [direction v] pressed?sensing blocks for each direction.
- For each If block, make your robot point toward the corresponding direction by adding
point in direction (90 v).
- Finally, add
move (5) stepsafter each point in direction (90 v)block.
- Your script should look like the image on the right.
- Try pressing the directional keys and see what happens!