Making one person who starts somewhere random.

 

1) Open up a fresh Scratch project (File menu, then New) and name it "DiseaseModel" (this mix of upper and lower case without spaces is called "CamelCase", and is quite common in programming, as is "snake_case"). Type the name in the projectname box at the top left:

 

Screenshot: new Sprite button

 

2) Right click on the Cat Sprite and delete it.

 

3) Click on the "Paint New Sprite" icon:

 

Screenshot: new Sprite button

This will take you to the costume tab where you can draw a new sprite.

 

4) Paint a new green sprite to represent our healthy person. Make it a circle not too large and not too small (Tip: if you hold the Shift key while drawing ovals they'll come out as perfect circles). Make sure it is some kind of green colour. Something like this:

Screenshot: new Sprite

Note: if you are colour blind in any way, feel free to use whatever colours or shapes you like; we'll be using green for healthy, red for infected, and black for dead, but subsitute for whatever you like. We'll always mention colours used in images in the text where a subsitution is important.

 

Using the naming box at the top of the drawing area (circled above), rename the new costume to "healthy". Then click the Scripts tab to go back the main editor screen.

 

5) Now we need to add the code to start the person somewhere on the screen. First, we need to add a start block. You can find these under "Events". Click on one and drag it into the script area:

Screenshot: start block

At the moment, although the program will run, nothing will happen. Let's add code to put the sprite somewhere random. Each sprite has an x-coordinate which controls its left-right position, and a y-coordinate that controls its up-down position. You can find blocks to set these under "Motion". Drag a Screenshot: set x to 0 and Screenshot: set y to 0 into the script and clip them to the start block:

Screenshot: set x and y

Now, we want to put them somewhere random on the screen. To do this we don't want x and y set to zero, but some random position. You can find a Screenshot: random random number maker under "Operators". Drag two of these into the spaces in "set x to 0" and "set y to 0" where the zeros are:

Screenshot: set x and y

These random number makers make numbers between 0 and 10 randomly. However, the left-right directions run from x = 240 to -240 and y = 180 to -180, with zero in the middle of the screen. Click on the numbers in the random number makers and set them to these numbers.

 

6) Now click the start flag and see where the sprite appears. Click the stop button and the start flag to check it appears somewhere else.

Go on to Making the person move randomly.