Bot Builders : Program Your Robot

Make your robot move


1
  1. In Scratch, When green flag clicked is used to start and reset games or projects.
  2. Make your own reset command by using it and attaching the these blocks shown on the right.
  3. Attach go to x:() y:() to reset your robot's position to your starting point.
  4. Indicate the value in x and y depending on where you want to set the starting point.

2
  1. Add broadcast [message1 v] to trigger a custom event.
  2. Click on the dropdown icon and select "New Message".
  3. Make the message, "randomize".
  4. This will be used to send a message to all the other sprites to move to a random position.

3
  1. Now, add forever for the main loop of your robot's code.
  2. Add four if <> then blocks for each direction your robot will walk.
  3. Add key [direction v] pressed? sensing blocks for each direction.
  4. For each If block, make your robot point toward the corresponding direction by adding point in direction (90 v).
  5. Finally, add move (5) steps after each point in direction (90 v) block.
  6. Your script should look like the image on the right.
  7. Try pressing the directional keys and see what happens!

BACK NEXT