Play Music and Move at the Same Time The playMelody code block allows us to play music with the robot. But it doesn't enable the robot to play music and move at the same time. To do this, we use the playMelodyNB command, where "NB" stands for non-blocking:
One thing to note: If RoboBlocky comes to the end of the program before the music is done, it will prematurely end the music as well. If you don't want the program to end until the music is done, then you must use the playNotesWait command at the end of the code:
|
playMelodyNB, playNotesWait
|
This example has the robot play the All Star melody while moving at the same time, using the playNotesWait block to make sure that the melody plays all the way through. (Delete the playNotesWait block and run the code again to see the difference.) |
The program below is an advanced example that creates an entire scene in a city. It makes use of non-blocking code blocks to create simultaneous motion and play music at the same time. |
Grid Size: S M L | Simple View: | MinView: |
|
Coord: x-axis y-axis | Grid Lines: x-axis y-axis | |||
Grid: | 12x12 inches | 24x24 inches | 36x36 inches | |
72x72 inches | 96x96 inches | 192x192 inches | ||
1x1 inches | 2x2 inches | Fraction: | ||
xy-Range: | ||||
|
||||
|
||||
Quad: | 1 Quadrant | 4 Quadrants | 1&4 Quadrants | |
Units: | US Customary | Metric | Ruler: |
Labels: |
|
|
|
Font
px
|
|
Tics Lines: |
|
Width
px
|
Hash Lines: |
|
Width
px
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
|
|||||||||||
|
|||||||||||