// Project 1 Julio Moya float x, y; float dx, dy; float horizon; float xSun=0, dxSun=1, ySun=50; float xGold=300, yGold=400; // SETUP void setup() { size( 800, 680 ); smooth(); horizon= height/2; reset(); } void reset() { x= mouseX; y= mouseY; dx= random( 4, 8 ); dy= random( 1.6, 3.9 ); } void draw() { scene(); action(); show(); messages(); street(); } // SCENE void scene(){ // Sky blue background( 102,255,255 ); fill( 0,180,0 ); // Grass noStroke(); rectMode( CORNERS ); rect( 0,horizon, width,height ); // Sun fill( 255,220,0 ); ellipse( xSun,ySun, 80,80 ); xSun= xSun + dxSun; if (xSun>width) { xSun= 5; ySun= random( 80, 20 ); } // House fill( 222,184,135 ); rect( width/7,horizon-100, 200+width/10,horizon ); triangle( 90,260, 305,260, 190,160); // Brown Door fill( 205,133,63 ); rect( 180,340, 220,290 ); // Window 1 fill( 102,255,255 ); rect( 130,320, 170,270 ); // Window 2 fill( 102,255,255 ); rect( 230,320, 270,270 ); // Tree fill( 165, 42, 42 ); rectMode( CORNER ); // Brown trunk rect( width*3/4, horizon, 40, -70 ); fill( 0,100,0 ); ellipse( 20+width*3/4, horizon-70-40, 120,120 ); } ///Name void messages() { fill(0); text( "Julio Moya Project 1", width/2,30 ); } void street () { fill( 0,0,0 ); rect( 200,500, 1600,125); // Median fill( 255,255,255 ); rect( 8,500, 1600, 8); } // ACTION: Monster void action() { x= x + dx; y= y + dy; } //Monster void show() { noStroke(); rectMode( CENTER ); // Body. fill( 0,0,0 ); rect( x,y, 80,80 ); // Head fill( 0,255,0 ); ellipse( x, y-50-20, 105,105 ); text( "Joe", x,y ); // Eye fill(255, 255, 255); ellipse( x-0, y-50-25, 95,55 ); fill( 65, 105, 225); ellipse( x-0, y-50-25, 40,40 ); // Gold fill( random(300,415), random(180,220), random(0,30) ); ellipse( xGold, yGold, 30, 20 ); } // click mouse void mousePressed() { reset(); xGold= mouseX; yGold= mouseY; }