// Day 4: // Example: snow removal the better way // mjh-2013 // initialize program size(600, 400); background(255); strokeWeight(10); stroke(0); // draw sidewalk and border with neighbour line(10, 100, 590, 100); line(10, 200, 590, 200); stroke(227, 0, 0); line(350, 75, 350, 225); textSize(30); fill(127); text("Your sidewalk", 20, 50); text("Neighbour", 350, 50); // let's shovel the snow fill(0); stroke(127); // keep a counter for each section we shovel // and we'll print this number on each // section that has snow removed int count = 0; // we can declare and initialize 2 or more // varables at the same time (if they are the // same type) int x = 25, y = 125; // shovel top half of snow while ( x < 350 ){ ellipse(x,y,50,50); count = count + 1; fill(250); // change colour for text text(count, x-15,y+15); // print number fill(0); // change colour back x = x + 50; } // shovel bottom half of snow // why do we need this next line? // x = x - 50; // better update x position!! // y = 175; // move down to bottom half while ( x > 0 ){ ellipse(x,y,50,50); count = count + 1; fill(250); // change colour for text text(count, x-15,y+15); // print number fill(0); // change colour back x = x - 50; }