Vorpal Robotics Wiki
Log in

Scratch Example Hello World

From Vorpal Robotics Wiki
Revision as of 20:42, 25 July 2018 by Vorpalwiki (talk | contribs) (Adding This Action To The Gamepad)

Purpose

This is a very simple Scratch program that will make Vorpal wave hello. It's a great way to get started.

Code

Scratch Hello World Program

Explanation

  • WHEN GREEN FLAG CLICKED: This block means that the program will start running when the green flag button (upper right corner of the scratch screen) is clicked. It just gives you a simple way to start the program.
  • REPEAT 3: This is a control block that causes the blocks inside it to execute three times in a row. You could get the same effect by simply repeating the blocks three times, but that would be more time consuming, plus by using the repeat block you can easily change the number of times Vorpal waves.
  • SET LEGS (two blocks): These two blocks actually make Vorpal wave. The first SET LEGS block moves leg number zero (front left leg) so that the knee puts the leg up in the air, but also sets the hip back a little. This movement is held for 0.2 seconds, just a short time. The second block leaves the leg up in the air but moves the hip forward, again for 0.2 seconds. Don't worry about the meaning of "mirror hips" yet, we will get to that in more advanced programs.
  • STOP: The stop block at the end resets Vorpal to a standing position and shuts down any other activities that might have been happening at the end of the program. It's always a good idea to end every program with a STOP block.

Adding This Action To The Gamepad

To create a way to trigger this motion from the gamepad, we simply have to enclose the repeat command in RECORD and RECORD END blocks like this:

Scratch Hello World Program, Gamepad Version