Modify a text file: $/Q1MR.pde
$/Q1MR.pde
//dynamic Project 1 MIguel R. //global declarartions float xMax, yMax ,xMaxspeed, yMaxspeed; float xRob, yRob, xRobspeed, yRobspeed; float xSun, ySun, xHouse, yHouse; float xTree, yTree; float horizon; float x,y; float randoms; //setup void setup() { size(500, 500); smooth(); reset(); xRob=0; xRob= height/50; xSun= width/15; ySun= 30; randoms= random(2,2); } void reset() { xMaxspeed= random(2,5); //random speed yMaxspeed= random(-3, +3); xMax= random(50, width-50); yMax= random(horizon+20, height-40); } //draw: sky,house,sun void draw() { scene(); action(); show(); messages(); } /////SCENE void scene() { background(0, 200, 250); ///sky noStroke(); ///sun fill(255, 255, 0); ellipse(xSun+250, ySun, 100, 100); fill(0, 200, 0); //grass rect(0, height/1.5, width, height-horizon); fill(150, 0, 0); //house rect(50, 220, 180, 180); fill(0, 0, 0); triangle(47, 220, 233, 220, 140, 130); //door fill(200, 100, 0); rect(110, 330, 50, 70); ellipse(135, 330, 50, 50); //knob fill(255, 255, 0); ellipse(155, 355, 10, 10); //windows rect(60, 250, 30, 50); fill(100,100,100); rect(170, 250, 50, 30); fill(0, 0, 0); rect(73, 250, 5, 50); rect(60, 270, 30, 5); rect(193, 250, 5, 30); rect(170, 265, 50, 5); fill(105, 100, 100); ellipse(135, 330, 30, 30); fill(0, 0, 0); rect(132, 315, 5, 30); rect(120,325,30,5); //tree fill(120,0,0); rect(400,300,30,100); strokeWeight(3); fill(0,200,0); ellipse(415,260,150,150); } void show() { heroShow(); dogShow(); } //characters void heroShow() { fill(0,120,100); //hero body rect(xMax+250,yMax+340,50,100); textSize(22); fill(250,120,0); text("MAX",xMax+252,yMax+370); //legs fill(200,190,100); rect(xMax+252,yMax+420,10,50); fill(200,190,100); rect(xMax+290,yMax+420,10,50); //head fill(200,190,100); ellipse(xMax+275,yMax+316,50,50); //eyes stroke(0); strokeWeight(2); fill(255,255,255); ellipse(xMax+265,yMax+310,15,15); fill(0,0,0); ellipse(xMax+267,yMax+310,5,5); stroke(0); strokeWeight(2); fill(255,255,255); ellipse(xMax+285,yMax+310,15,15); fill(0,0,0); ellipse(xMax+286,yMax+310,5,5); } //dog void dogShow(){ //body fill(250,120,0); rect(xRob+100,yRob+390,100,50); fill(0,120,100); text("ROB", xRob+110,yRob+410); //legs fill(0,0,0); rect(xRob+105,yRob+420,20,50); fill(0,0,0); rect(xRob+155,yRob+420,20,50); //neck strokeWeight(15); stroke(0); line(xRob+200,yRob+390,xRob+215,yRob+360); //dog head// fill(0,0,0); rect(xRob+210,yRob+340, 45,45); //eyes strokeWeight(1); fill(255,255,255); ellipse(xRob+250,yRob+350,20,20); fill(0); ellipse(xRob+250,yRob+350,7,7); //ears// fill(255,255,255); triangle(xRob+205,yRob+334,xRob+215,yRob+320,xRob+230,yRob+334); triangle(xRob+230,yRob+334,xRob+240,yRob+320,xRob+260,yRob+334); } ////ACTION void action() { //sun movbes if (xSun > width) { xSun=0;} xSun= xSun+1; //xMax if (xMax>width-20 || xMax<0) {xMaxspeed *=1; } if (yMax>height) {yMaxspeed *=-1;} if (yMax> height) {yMax=0;} if (yMax
width) {xMax=0;} xMax= xMax+ xMaxspeed; yMax= yMax+ yMaxspeed; //dog follow xRob= xRob + (xMax-xRob) /90; yRob= yRob + (yMax - yRob) /90; } void keyPressed() { if (key== 'l') xSun= xSun-9; } { if (key == 'q') exit(); } { if (key=='r'); reset(); } {if (key=='t'); xMax= xMax+50;} //move bot n mutt //xRob= xRob + (xMax-xRob) /90; void messages() { }