Modify a text file: $/p1.pde
$/p1.pde
//Project 1 //Fernando Pantaleon float xDog, yDog; float xHuman, yHuman; float xSol, ySol; float dxSol; float dySol; float xTree, yTree; float dxHuman; float dyHuman; float horizon; float dxDog; float dyDog; //Setting it up void setup() { size (850, 650); reset(); } void reset() { xSol = width/2; ySol = 50; xHuman = width/2; yHuman = width/2; xDog = xHuman - 100; yDog = xHuman + 50; dxHuman = 3; dyHuman = 3; dxDog = 3; dyDog = 3; xTree = 600; yTree = 114; } void draw() { scene(); illustrate(); motion(); messages(); } void scene() { background(150, 120, 150); fill(190, 255, 51); rect(-4, 150, 900, 755); fill(255,0,0); rect(100,100,100,50); //The Red House triangle(100,100,200,100,150,75); fill(10,0,0); rect(105,110,20,40); fill(255,255,0); ellipse(120,120,10,10); fill(255,255,255); rect(135,115,15,25); rectMode(CENTER); fill(105,150,0); rect(xTree,yTree,20,70); fill(20,130,10); ellipse(xTree,yTree- 50,80,80); } void illustrate() { rectMode(CORNER); strokeWeight(0); fill( 0,0,245); ellipse( xHuman, yHuman, 40, 90); //the body fill(255, 204, 102); ellipse( xHuman ,yHuman-60, 50, 50); // The Head fill(255); strokeWeight(1); ellipse( xHuman-12, yHuman-65, 12, 12); // The eyes ellipse( xHuman+12, yHuman-65, 12, 12); fill(0); ellipse( xHuman-12, yHuman-65, 3, 3); ellipse( xHuman+12, yHuman-65, 3, 3); fill(102, 051, 0); rect( xDog, yDog, 60, 35); // The dog rect( xDog+45, yDog-20, 35, 20); fill(255); ellipse( xDog+55, yDog-15, 12, 12); fill(255,255,255); ellipse( xDog+55, yDog-15, 3, 3); text( "Human", xHuman-20, yHuman-15); text( "Dog", xHuman-80, yHuman+75); fill(255,255,0); ellipse( xSol, ySol, 60,60); } void motion() { if (xSol > width) { xSol= 0; ySol= random (20, 100);} { // if (xSun > width) // dxSun= random(1, 10); } xSol= xSol + 1; //Move Human xHuman = xHuman + dxHuman; yHuman= yHuman + dyHuman; // bounce of the wall if ((xHuman > width) || (xHuman<0)){ dxHuman= dxHuman * -1; } if (yHuman > height || (yHuman < 0)){ dyHuman = dyHuman * -1; } //Dog follows Human xDog = xHuman- 100 + dxHuman; yDog= yHuman+ 50 + dyHuman; } void messages() { fill(0); text( "Fernando",3, 595); text ( " Press 'p' to quit", 1, 300); text( " Press 'g' to move tree", 600, 175); } // Key actions! void keyPressed() { if (key == 'p') { exit(); } if (key == 'g'){ xTree= random( 600, 790); } }