/* Arguments may be used as local variables inside the body of a function (class) that get filled with values when the function is called Arguments are added in the constructor as temporary variables that are given specific values when the objects based on the class are written This allows us to make a variety of objects using the same constructor */ Land myLand0; Land myLand1; Land myLand2; Land myLand3; void setup() { size(800, 600); myLand0 = new Land(color(245,215,175), random(0,50), random(0,50), random(100,150), random(0,50), random(450,600), random(500,600), random(250,400), random(500,600), .4); myLand1 = new Land(color(255,230,77), random(400,500), random(0,50), random(600,800), random(0,50), random(300,500), random(550,600), random(150,250), random(550,600), -.1); myLand2 = new Land(color(200,130,55), random(200,300), random(550,600), random(400,500), random(550,600), random(500,650), random(-200,-300), random(350,400), random(-200,-300), .2); myLand3 = new Land(color(20,30,200), random(-300,-350), random(400,450), random(400,450), random(400,450), random(400,450), random(500,550), random(-300,-350), random(500,550), .1); smooth(); } void draw() { background(255); myLand0.move(); myLand0.display(); myLand1.move(); myLand1.display(); myLand2.move(); myLand2.display(); myLand3.move(); myLand3.display(); } class Land { color c; float xpos1; float ypos1; float xpos2; float ypos2; float xpos3; float ypos3; float xpos4; float ypos4; float xspeed; float yspeed; Land(color c_, float xpos1_, float ypos1_, float xpos2_, float ypos2_, float xpos3_, float ypos3_, float xpos4_, float ypos4_, float xspeed_) { c = c_; xpos1 = xpos1_; ypos1 = ypos1_; xpos2 = xpos2_; ypos2 = ypos2_; xpos3 = xpos3_; ypos3 = ypos3_; xpos4 = xpos4_; ypos4 = ypos4_; xspeed = xspeed_; //yspeed = yspeed_; } void display() { stroke(0); fill(c); quad(xpos1, ypos1, xpos2, ypos2, xpos3, ypos3, xpos4, ypos4); } void move() { xpos1 = xpos1 + xspeed; //ypos1 = ypos1 + xspeed; xpos2 = xpos2 + xspeed; //ypos2 = ypos2 + xspeed; xpos3 = xpos3 + xspeed; //ypos3 = ypos3 + xspeed; xpos4 = xpos4 + xspeed; //ypos4 = ypos4 + xspeed; if (xpos1 > width+1000 || ypos1 > height+800){ xpos1 = 0; } } }