Option 2: Solid
Part 1: Set Up
1. Create a relevant backdrop using the paint editor and add instructions to the backdrop using the text tool, if desired.
2. Add a sprite (i.e., the “ball” sprite can serve as a representation of the particles) and delete all the costumes for that
sprite except for one. Use the paint bucket in the paint editor to set it to a solid colour to make interactions between
each particle sprite easier to detect.
3. Create two versions of this sprite with different colours so you can visually tell the difference and be sure to name
them clearly. For the remainder of this lesson, they will be referred to as the “red particle” and “black particle” (but
you can choose any colour).
4. In the orange Variables menu, click “Make a Variable”.
a. Name the new variable “Temperature” and select the checkbox so that the variable appears on screen.
b. When the variable appears on the project preview screen, right click it and select Slider. This will allow the
user to change the temperature in order to eventually impact the speed at which the particle sprites move.
c. You can reposition the variable on screen by clicking and dragging.
Part 2: Create the Container Sprite
1. Use the paint editor to design a sprite to be some kind of fully enclosed shape (i.e., a box). The shape should be an
outline only with no fill colour and the recommended pen size for the line thickness is approximately 10. No code
is needed in this sprite.
Part 3: Settings for Red Particle
1. In the area for the particle sprite, add the When Green Flag Clicked event block.
2. Use the Set () To () block from the variables menu and change it to match with the name of your temperature
variable. Setting it to a low number (i.e., 10) will make it so that when your code begins. the particles will already
be in motion.
3. Use the Set Size To ()% block to resize the particle sprite such that approximately 10 – 12 particles can fit within the
container sprite (i.e., if using the default ball sprite from Scratch’s pre-designed sprites, a size of 50%-75% works
well).
4. Use a Forever loop and add the following blocks inside to create the effect of the particles vibrating back and forth:
a. Add a Change X by () block combined with a () / () operator block and set the first blank space of the () / ()
block to the round block with your temperature variable name from the variables menu. Set the second
blank space to a value such as 10. This will make it so that as the temperature variable is increased or
decreased with the slider, the movement of the particle sprites will speed up or slow down accordingly.
b. Use a Wait () Seconds block and set it to 0.1 seconds. This will create a slight delay between the left and
right movement so that it is visible to the viewer.
c. Use the same block as in step (a) above but change the value to -10 to cause a movement in the opposite
direction.
Part 4: Settings for Black Particle
1. The code for the black particle will be the same as for the red particle but with one subtle change. To copy the code
from one sprite to another, click and drag the code by the topmost block in the script (i.e., in this case, by the event
block) and drag it into the icon for the desired sprite in the sprite pane.
2. Once the code has been copied to the black particle, change the order of the +10 and -10 values (i.e., if in the red
sprite the order was +10 and then -10 then in the black particle, the order should be -10 and +10).
Part 5: Create Many Particles
1. Each red particle sprite and black particle sprite will have the exact same code, respectively. As a result, you can
just duplicate the sprites you have already created in order to make as many particles as you desire (i.e., in the
sample code, there are six of each for a total of 12). To create a duplicate, right click on the icon of the sprite in the
sprite pane and select “Duplicate.” Remember that if you make any changes in a particle sprite, you will need to
replicate those changes in all of the other sprites.