Modify a text file: $/Background_Change.pde
$/Background_Change.pde
//Background // George Marmol float sunX, sunY; // Position of sun float x, y; // Position and speed of creature. float dx, dy; //// SETUP: Define screen size, set modes. void setup() { size( 600, 400 ); reset(); } void reset() { sunX= width/2; // Start the sun half-way across the screen. sunY= 50; x= width/2; // Start person in center. y= height/2; dx= random( 2,5 ); // Random speed. dy= random( -2, +2 ); } //// DRAW: sky & sun plus creature void draw() { scene(); show(); } //// SCENE: sky, sun, house. void scene() { background( 255, 255, 255 ); // Blue sky fill( 255, 255, 0 ); ellipse( sunX, sunY, 30, 30 ); // Yellow sun fill( 200, 159, 235 ); rect( 100,100, 100,80 ); // Red house triangle( 100,100, 200,100, 150,50 ); } //// ACTION: sun moves (then resets to random height) //// SHOW: Person follows mouse void show() { // Draw creature. fill( 140, 110, 200 ); rect( x,y, 50, 80 ); // Blue creature ellipse( x+25, y-20, 40, 40 ); // Head on top // Eyes. fill( 255 ); ellipse( x+15, y-25, 12, 12 ); ellipse( x+35, y-25, 12, 12 ); fill( 0, 150, 0 ); ellipse( x+15, y-25, 4, 4 ); ellipse( x+35, y-25, 4, 4 ); } //// EVENT HANDLERS //// void mousePressed() { reset(); // Set the position (x,y) x= mouseX; y= mouseY; } void keyPressed() { if (key == 'q') { exit(); } if (key == 'r') { reset(); } if (key == 's') { sunY= sunY + 50; } if(key=='v'){ background(0,0,0);} } ///