Modify a text file: $/p1.txt
$/p1.txt
//Aiden Solis Project float sunX, sunY; // Position of sun float x, y; // Position and speed of man. float dx, dy; float dogX, dogY; float dogW=80, dogH=40; //Setup Define screen size, set modes. void setup() { size( 600, 600 ); reset(); dogX= 0; // Start dog at left. dogY= height/2; } void reset() { sunX= width/2; // Start the sun half-way across the screen. sunY= 40; x= width/2; // Start man in center. y= height/2; dx= random( 2,5 ); // Random speed. dy= random( -2, +2 ); } //Draw sky & sun plus man void draw() { scene(); action(); man(); dog(); messages(); } void dog() { //draw doggo fill( 222, 144, 0 ); rect( dogX, dogY, dogW, dogH ); float headX=dogX+dogW*3/4; rect( headX, dogY, dogW/2, -dogH/2 ); // Eye. fill( 255 ); ellipse( headX+15, dogY-dogH/2+5, 12, 12 ); } //Scene Sky Sun Tree House. void scene() { //Sky background( 150, 200, 250 ); //Grass fill(0,255,0); rect(0,400,600,200); //Sun fill( 255, 255, 0 ); ellipse( sunX, sunY, 40, 40 ); //Tree fill( 222, 144, 0 ); rect( 80,320, 40,100 ); fill(0,255,0); ellipse(100,300,100,80); //House fill( 255, 0, 0 ); rect( 200,350, 100,50 ); triangle( 200,350, 300,350, 250,300 ); fill(0,155,255); rect( 210,350, 20,20 ); rect( 270,350, 20,20 ); fill( 222, 144, 0 ); rect( 240,355, 20,45 ); fill(0,155,255); ellipse(250,365,10,10); } //// MESSAGES. void messages() { fill(0); text( "Man resets on click, while sun moves across the sky Press Q to quit.", width/3, 20 ); //My name text( "Aiden Solis Project 1", 10, height-10 ); } //// ACTION: sun moves (then resets to random height) with man wall bounce void action() { if (sunX > width) { sunX= 0; sunY= random( 20, 120 ); } sunX= sunX + 1; // Move man x= x + dx; y= y + dy; if (x>width) { dx = -dx; } if (x<0) { dx = -dx; } if (y>height) { dy = -dy; } if (y<0) { dy = -dy; } } void man() { // Draw man // Body fill( 255, 0, 0 ); rect( x,y, 45, 70 ); // Head fill(255,255,255); ellipse( x+25, y-20, 60, 60 ); // Eyes. fill( 255 ); ellipse( x+15, y-25, 16, 20 ); ellipse( x+35, y-25, 16, 20 ); fill( 0, 150, 200 ); ellipse( x+15, y-25, 8, 8 ); ellipse( x+35, y-25, 8, 8 ); // Arms line(x+48,y+5,x+60,y+60); line(x,y+5,x-12,y+60); //legs line(x+48,y+70,x+60,y+120); line(x,y+70,x-12,y+120); } //// Events void mousePressed() { reset(); // Set the position (x,y) x= mouseX; y= mouseY; } void keyPressed() { if (key == 'q') { exit(); } } //