Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
In this add-on, you'll turn the Mona Lisa
into a boombox using a music loop
and a fisheye effect.
This example project doesn't have any other code right now,
but it's okay if your project has code.
You can program this add-on to work
with your existing code.
To start, program a sound to play repeatedly.
Click the Sounds tab, and select Choose Sound from Library.
To find a sound that works well in a music loop,
select the Music Loops category.
Select a sound you like.
(voice beatboxing rapidly)
Now program this sound to play.
Click the Sound menu.
Drag out a Play Sound Until Done block.
Make sure that the sound you chose
is selected in the block, and click to run it.
To loop this, click Control
and add a Forever block.
This will play the sound over and over
until you click the stop sign.
Click to try it.
If the sound in your program isn't playing
how you thought it would, make sure
that you've added a Play Sound Until Done block,
not a Play Sound block.
Great, now the sound is looping.
To run this code at the start of the program,
add a When Flag Clicked block.
Next make it look like the painting
is playing the music using a fisheye effect.
Click Looks and drag out a Change Color Effect By block.
Click to run it.
The Mona Lisa changed colors!
Click the drop-down to see all effects
that you can use to change the appearance
of a sprite.
Select Fisheye and click to run it.
To clear effects, drag out the Clear Graphics block
and click to run it.
Clicking these two blocks repeatedly
gives a sense of the boombox effect
that you'll create.
As a computer scientist, you can program
the computer to repeat these effects
so you won't need to keep clicking.
Drag out a Forever loop and place
the two effect blocks inside.
Huh, it doesn't look like anything is happening.
This is because the computer is running
the two blocks as fast as it can,
so fast that you can't see the effects.
To fix this, program the computer to wait
between changing the effects.
Click Control and add a Wait block.
Tinker with the values in these Wait blocks
to speed up or slow down the effects.
Now all that's left is to add a When Flag Clicked block
to run the code with the music loop
at the start of the program.
Try it out!
Now it's your turn.
Choose a sound from the Sounds tab
and program it to play
using the Play Sound Until Done block.
Use a Forever loop and a When Flag Clicked block
to play the music loop for the entire program.
Use a Change Fisheye Effect block,
Wait blocks, a Clear Graphics Effect block,
and a Forever loop to create a boombox effect.
Add a When Flag Clicked block
to get your boombox effect and the music
to both happen when the flag is clicked.