Modify a text file: $/p1WIP.txt
$/p1WIP.txt
// float sunX, sunY; // Position of sun float x, y; // Position and speed of man. float dx, dy; // Setup Define screen size, set modes. void setup() { size( 600, 600 ); reset(); } 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(); show(); } // Scene Sky Sun Tree. 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); } //// ACTION: sun moves (then resets to random height) void action() { if (sunX > width) { sunX= 0; sunY= random( 20, 120 ); } sunX= sunX + 1; // Move man x= x + dx; y= y + dy; } void show() { // 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,255,255 ); ellipse( x+15, y-25, 16, 22 ); ellipse( x+35, y-25, 16, 22 ); fill( 0, 150, 0 ); 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; } //