Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
In this add-on,
you will add a sprite that breakdances
to the music your DJ sprite is spinning.
To get started, select a new sprite with multiple costumes
to add to your project.
Here, you can see how many costumes the sprite has
by clicking on the costumes tab.
Once you have a sprite with multiple costumes,
switch to the code tabs to add the code
to make the sprite dance.
To make the sprite dance,
you can use any combination of move, glide, next costume,
and weight blocks to achieve the look that you want.
In this example,
the breakdancer will glide to the left, switch costumes,
glide to the right, then switch costumes again.
To put the dance code,
drag this sprite slightly to the left
where you want it to glide.
Then, from the motion menu,
drag out a glide one second to XY block.
The location where X and Y values are prepopulated
depending on where you place the sprite.
To make the sprite change costumes,
go to the looks menu and drag out a next costume block
and connect that to the glide block.
Now, move the sprite where you want it to glide next
and drag out another glide one second block
from the motion menu.
Connect it to the block stack.
Now drag out one more next costume block from the looks menu
and connect it to the bottom of the dance block stack.
Test your code by clicking on the block stack.
This dance looks pretty good,
but you can dig it with the values to add
other motion and weight blocks to make the dancer move
any which way you like.
The make the sprite dance forever,
drag out a forever loop from the control menu
and place it around the dance block stack.
It's also a good idea to have your sprite start
in the same spot every time the program runs.
To do that, drag the dancer
where you want it to start on the stage.
Then, go to the motion menu and drag out a go to XY block.
Remember, the spot where you placed the sprite
is now prepopulated in the X and Y values
for the go to block.
You also need to tell the computer
when to run this code.
Drag out a when green flag click block from the events menu
and place it at the very top
of your dancing sprite block stack.
Test the code now by clicking on the green flag.
The breakdancer moves with the music.
Now it's your turn.
Add a sprite with multiple costumes.
Use any combination of move, glide, next costume,
and weight blocks to create the dance you want.
Place a forever loop around the dance blocks
to make this sprite dance forever.
Give your dancing sprite a starting location
with a go to XY block.
And lastly add a when green flag clicked event
to the top of your block stack.