Lesson 4

Shapes and Random Numbers


In this lesson I learned how to change the size of shapes. The rectangle and ellipse blocks now have 4 parameters (x-location, y-location, width, height).

I also learned how to use the random number block which allows me to set a parameter to a range of numbers instead of just one fixed number. In this scene, the purple object moves location when the code is reset becasue its x and y location are set to use random numbers.

noStroke();

// Draw sky
background("skyblue");

// Draw sun
fill("yellow");
ellipse(350,50,50,50);
fill("black");
ellipse(362,41,10,10);
fill("black");
ellipse(343,41,10,10);
fill("black");
ellipse(350,61,20,10);

// Draw moon
fill("purple");
ellipse(randomNumber(25, 375),randomNumber(0, 275),50,50);

// Draw grass
fill("green");
rect(0,300,400,100);