Modify a text file: $/q1.pde
$/q1.pde
//Farah Rashid //Exam 1 // 03/04/2020 // String title = "Project #1"; String owner = "Farah Rashid"; String hint = "Click to move rocky"; //Global Declarations float x,y; float horizon; float xMoon= 0, yMoon = 50; float xrocky, yrocky; float xfranky, yfranky; float gx, gy; float xHouse, yHouse; float xTree1, yTree1, xTree2, yTree2, xTree3, yTree3; float xMonster, yMonster; boolean day = true; boolean night = true; //set the size of the output window void setup() { size( 800,600); smooth(); horizon = height/2; reset(); resetrocky(); } //reset void reset() { xfranky = width/2; yfranky = height/2; gx = random(2,5); gy= random (-2,+2); } //Draw void draw() { scene(); drawrocky(); action(); messages(); show(); monster(); } void scene() { if (!day) {background(206,35,67);} if (day) { background (106,135,227);} fill(96,247,32); rect(-2,50+horizon, 900,900); //moon stroke(10); if (!day) { fill( 157, 154, 133);} //grey if (day) { fill( 255, 226, 0);} //yellow ellipse(xMoon, yMoon, 80,80); //green grass fill(0,150,0); y= height/1.2; x=0; while( x< width) { line(x,y,x,y-10); x= x+20; strokeWeight(1); //brown rocks fill(214,103,39); y= height/1.1; x= -1; while (x< width) { ellipse(x,y,30,20); x = x+50; } } //house //Tree1 stroke(1); strokeWeight(5); fill(222,163,36); // green color rect(500,290,50,100); fill(0,200,0); ellipse(525,250,100,100); //Tree2 //pink color fill(222,163,36); rect(400, 290, 50,100); fill(242,42,149); ellipse(420,260,100,100); //Tree3 fill(222,163,36); //yellow color rect(600,290,50,100); fill(248,252,15); ellipse(630,250,100,100); //house fill(62,15,252); //blue color rect(90,150,250,200); //door fill(10); rect(150,250,90,100); //knob fill(255); //white color stroke(1); ellipse(175, 300, 20,20); } void drawrocky() { y = height/1.5; x=500; //face stroke(10); strokeWeight(4); fill(255,0,0); line(xfranky, -35+yfranky, xfranky, -65+yfranky); ellipse(-17.5+xfranky, -65+yfranky, 65,45); ellipse( 17.5+xfranky, -65+yfranky, 65, 45); arc(0+xfranky, -65+yfranky, 70,70,0,PI); //body fill(254, 256, 0); ellipse( xfranky-1, yfranky+10, 50,100); //left and right eye and nose fill(255); ellipse( -17+xfranky, -65+yfranky, 10,10); ellipse( 17+xfranky, -65+yfranky, 10,10); ellipse( xfranky,yfranky- 50, 10,10); //small black circles on the body fill(10); ellipse(xfranky,yfranky-15,10,10); ellipse(xfranky,yfranky+30,10,10); ellipse(xfranky,yfranky+8,10,10); //right and left fill( 255, 158, 0); ellipse( xfranky-36, yfranky, 20,40); ellipse( xfranky+36, yfranky, 20,40); //right and left paws fill(255,158,0); ellipse(xfranky-25, yfranky+65, 25, 45); ellipse(xfranky+25, yfranky+65, 25, 45); } void show() { //franky stroke(0); strokeWeight(1); fill(#39FFF0); //sky blue rect( xfranky, yfranky, 30, 80); fill(#FEFF46); //yellow ellipse(xfranky+15, yfranky -15, 50,50); fill(0); //black ellipse(xfranky + 13, yfranky - 23, 12, 12); ellipse(xfranky + 29, yfranky - 23, 12, 12); fill(#FFFFFF); ellipse(xfranky + 13, yfranky - 23, 8,8); ellipse(xfranky + 29, yfranky - 23, 8,8); } // draw a monster void monster() { //body stroke(0); strokeWeight(5); fill(8,8,6); rect(400,450, 60,100); //face stroke(1); strokeWeight(0.5); fill(0); //black ellipse(430,430, 50,50); //one eye fill(255); //white ellipse(430,430, 20,20); fill(255,3,3); //red ellipse(430,430,15,15); //left and right leg fill(0); //black rect(411,551, 10,40); fill(0); //black rect(440, 551, 10,40); //left right feet fill(0); //black rect(405, 585, 19,10); rect(435, 585, 19,10); } //void reset rocky void resetrocky() { xrocky = random(10, width -10); yrocky = random(horizon, height-10); } void messages() { fill(255); text( "Dynamic sketch." , width/2, 20); //author and file name fill(10); text( "Farah Rashid/ p1.pde", 10, height-5); } void action() { xMoon = xMoon +2; if (xMoon > width) { xMoon = 0; yMoon = 50; day= !day; } if (xfranky> width) { gx = -gx; } if (xfranky<0) { gx = -gx; } if (yfranky> height) { gy = -gy; } if (yfranky< horizon) { gy = -gy; } xfranky= xfranky + gx; yfranky= yfranky + gy; } void keyPressed() { if (key == 'd') { reset ();} if (key == 'n') { reset ();} if (key == 'q') { exit(); } if (key == 'r') { reset (); } } void mousePressed() { xfranky = mouseX; yfranky = mouseY; }