Modify a text file: $/x224Castellanos_Cooper_chases_Isabella.pde
$/x224Castellanos_Cooper_chases_Isabella.pde
//Project 1 //Ileana Castellanos //// GLOBAL DECLARATIONS //// // (x,y) coordinates of hero, dog, etc. float xIsabella, yIsabella, xIspeed, yIspeed; float xCooper, yCooper, xCspeed, yCspeed; float xSun, ySun, xHouse, yHouse; float xTree1, yTree1, xTree2, yTree2; float horizon; float x, y; //setup void setup() { size(800, 600); horizon = 350; smooth(); xSun= width/15; ySun= 75; reset(); } void reset() { xIsabella= 100+width/4; yIsabella= horizon+70; xIspeed= random(2,5); yIspeed= random(1,3); xCooper= width/4; yCooper= horizon+50; xCspeed= random(4,6); yCspeed= random(3,5); } //Draw: sky, sun, grass, house, person, dog, etc. void draw() { //SCENE:sky, sun, grass, house, person, dog, etc. // blue sky background (180, 230, 230); //green grass fill (160, 200, 160); rect (0, horizon, 800, 600); //sun noStroke(); fill (255, 255, 0); fill(255, 255, 0); ellipse(xSun, ySun, 100, 100); //clouds stroke(150); fill (255, 255, 255, 180); ellipse (250, 80, 200, 50); ellipse (500, 80, 200, 50); ellipse (400, 130, 200, 50); stroke(0); house(); trees(); //hero Isabella //body fill(250, 0, 100); rect(xIsabella, yIsabella, 50, 100); //head fill(200, 190, 100); ellipse(xIsabella+25, yIsabella-25, 50, 50); //eyes fill( 255 ); ellipse( xIsabella+15, yIsabella-32, 9, 9 ); ellipse( xIsabella+35, yIsabella-32, 9, 9 ); //smile // arc( //dog Cooper //body fill(250, 120, 0); rect(xCooper, yCooper, 100, 50); //head rect(xCooper-20, yCooper-20, 50, 30); //nose fill (0, 0, 0); ellipse(xCooper-20, yCooper-20, 12, 8); //eyes fill (255); ellipse(xCooper+20, yCooper-12, 12,12 ); fill (0,100,255); ellipse(xCooper+20, yCooper-12, 6,6 ); action(); } void action() { //ACTION// if (xSun > width) { xSun=0; } xSun= xSun+1; // Move the hero Isabella if (xIsabella > width-30) { xIspeed = -xIspeed; } if (xIsabella < 20) { xIspeed = -xIspeed; } if (yIsabella > height-30) { yIspeed = -yIspeed; } if (yIsabella < horizon) { yIspeed = -yIspeed; } xIsabella= xIsabella + xIspeed; yIsabella= yIsabella + yIspeed; // Move dog Cooper to chase Isabella xCspeed= (xIsabella-xCooper) / 60; yCspeed= (yIsabella-yCooper) / 60; xCooper = xCooper + xCspeed; yCooper = yCooper + yCspeed; } void house() { //house stroke(0, 50, 0); fill(255, 200, 70); rect(400, horizon-200, 200, 200); //blue door fill(46, 136, 242); rect(465, horizon-90, 70, 90); fill(0); //knob fill(255, 0, 255); ellipse(525, horizon+5, 10, 10); //door window fill(255, 255, 255); ellipse(500, horizon-20, 30, 30); //roof fill(0, 0, 0); triangle(400,horizon-200, 500,horizon-300, 600,horizon-200 ); //windows fill(93, 50, 10); fill(22, 200, 146); //left rect(410, horizon-150, 50, 50); //right rect(540, horizon-150, 50, 50); //line(200, 105, 100, 115); //line(100, 110, 105, 110); //line(120, 105, 120, 115); //line(115, 110, 125, 110); } void trees() { //tree 1 stroke(0, 0, 0); fill(200, 50, 50); rect(100, 395, 30, 105); stroke(0, 0, 0); fill(200, 255, 100); ellipse(115, 360, 70, 70); //tree 2 stroke(0, 0, 0); fill(200, 50, 50); rect(250, 395, 30, 105); stroke(0, 0, 0); fill(200, 255, 100); ellipse(265, 360, 70, 70); }