Modify a text file: $/pr1MR.pde
$/pr1MR.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; //setup void setup() { size(500, 500); smooth(); reset(); xTree = width/1.5; yTree = height/1.7; yMax = height/1.5; xMax = width/2; xRob= width/12; yRob= height/1.3; xSun= width/2; ySun= 30; } void reset() { } //draw: sky,house,sun void draw() { background(0, 200, 250); ///sky noStroke(); ///sun fill(255, 255, 0); ellipse(xSun, 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(xTree, yTree, 30, 100); strokeWeight(3); fill(0, 200, 0); ellipse(xTree+15, yTree-60, 150, 150); fill(0, 120, 100); //hero body rect(xMax, yMax, 50, 100); textSize(22); fill(250, 120, 0); text("MAX", xMax, yMax+40); //legs fill(200, 190, 100); rect(xMax, yMax+90, 10, 50); fill(200, 190, 100); rect(xMax+40, yMax+90, 10, 50); //head fill(200, 190, 100); ellipse(xMax+27, yMax-25, 50, 50); //eyes stroke(0); strokeWeight(2); fill(255, 255, 255); ellipse(xMax+16, yMax-30, 15, 15); fill(0, 0, 0); ellipse(xMax+15, yMax-30, 5, 5); stroke(0); strokeWeight(2); fill(255, 255, 255); ellipse(xMax+35, yMax-30, 15, 15); fill(0, 0, 0); ellipse(xMax+34, yMax-30, 5, 5); //dog //body fill(250, 120, 0); rect(xRob, yRob, 100, 50); fill(0, 120, 100); text("ROB", xRob+30, yRob+20); //legs fill(0, 0, 0); rect(xRob+70, yRob+40, 20, 50); fill(0, 0, 0); rect(xRob, yRob+40, 20, 50); //dog head// fill(0, 0, 0); rect(xRob+80, yRob-40, 45, 45); //eyes strokeWeight(1); fill(255, 255, 255); ellipse(xRob+115, yRob-30, 20, 20); //ears// fill(255, 255, 255); triangle(xRob + 75, yRob - 40, xRob + 90, yRob-80, xRob+100, yRob-40); triangle(xRob+110, yRob - 40, xRob +125, yRob-80, xRob+135, yRob-40); //scene //SUNMOVE xSun = xSun + .5; if (xSun > width) { xSun=0; } xSun= xSun+.5; //hero move xMax = xMax + 1; if (xMax > width) { xMax= random(width); } if (yMax> height) { yMax= random(height); } yMax = yMax + random(1); // Dog follow xRob= xRob + (xMax-xRob) /400 ; yRob= yRob + (yMax-yRob) /400 ; } ////ACTION //sun movbes void keyPressed() { if (key == 'q') exit(); if (key=='r'); reset(); } void messages() { }