int x=1; int dx=1; int y=1; int fx=mouseX; int fy=mouseY; color yellow =color(200,200 , 0); color blue =color(0, 200, 255); color dblue =color(0,0,100); color lblue=color(100,100,225); color green =color(0, 150, 0); color red=color(250,0,0); color white=color(250,250,250); float dragonX=750; float dragonY=100; float small=1; PShape dragon; void setup() //void setup { size(800, 800, P2D); background(0, 64, 51); //grass strokeWeight(6); fill(lblue); rect(0, 0, 1000, 350); //sky } void draw() //void draw { environment(); sun(); clouds(); frog(); dragon(); text(); } void environment() { background(0, 64, 51); //grass strokeWeight(6); if (x+50>500) //night sky { fill(dblue); } if (x+50<500) //morning sky { fill(blue); } rect(0, 0, 1000, 350); //sky strokeWeight(2); fill(100, 200, 200); rect(250, 250, 200, 200); //house strokeWeight(2); fill(255, 100, 0); rect(400, 125, 50, 100); //chimney fill(0, 0, 0); triangle(350, 150, 500, 250, 200, 250); //roof strokeWeight(2); fill(255, 0, 50); rect(350, 370, 50, 80); //Door strokeWeight(2); fill(255, 255, 255); rect(280, 275, 50, 50); //left window strokeWeight(2); fill(255, 255, 255); rect(375, 275, 50, 50); //right window } void sun() { if (x+50>500) { //change sun to moon fill(lblue); } if (x+50<500) { //change moon to sun fill(yellow); } ellipse(x, 180, 100, 100); //sun x=x+dx; if (x+50>width) //sun path { dx = -1; } if (x-50<0) //sun path reverse { dx=1; } } void clouds() { fill(white); ellipse(x+500, 100, 75, 50); //cloud 1 ellipse (x-300, 150, 100, 50); //cloud 2 ellipse(x-50, 220, 100, 50); //cloud 3 } void frog() { scale(.75); fx=mouseX; fy=mouseY+100; fill(green); rect(fx+25,fy+50,200,100,25); // frog body rect(fx+150,fy+25,75,50,25); //frog eye fill(green); rect(fx+25,fy+125,75,35,25); //frog front foot rect(fx+175,fy+125,75,35,25); //frog back foot fill(255,255,255); rect(fx+185,fy+40,40,20,5); //frog pupil fill(0,0,0); rect(fx+200,fy+40,5,5); } void text() { fill(blue); strokeWeight(2); text("RMS-change the time of day with the Mouse",50,50); //Text textSize(32); text("Kill the dragon with the F key",0,height+200); } void dragon() { PShape dragon = createShape(GROUP); PShape head = createShape(); head.beginShape(); head.fill(255, 0, 0); head.stroke(2); head.vertex(0, 100); head.vertex(10, 75); //head head.vertex(40, 50); head.vertex(75, 0); head.vertex(90, 40); head.vertex(200, 10); head.vertex(120, 120); head.vertex(50, 110); head.endShape(CLOSE); fill(255, 0, 0); PShape neck = createShape(RECT, 75, 110, 30, 80); //neck fill(255, 0, 0); PShape body = createShape(RECT, 15, 165, 150, 120, 5); //body PShape lwing = createShape(); lwing.beginShape(); lwing.fill(255, 0, 0); lwing.stroke(2); lwing.vertex(30, 170); lwing.vertex(-75, 100); lwing.vertex(-75, 300); //left wing lwing.vertex(-35, 200); lwing.endShape(CLOSE); PShape rwing = createShape(); rwing.beginShape(); rwing.fill(255, 0, 0); rwing.stroke(2); rwing.vertex(150, 175); rwing.vertex(250, 100); rwing.vertex(250, 300); //right wing rwing.vertex(200, 200); rwing.endShape(CLOSE); PShape lfoot = createShape(); lfoot.beginShape(); lfoot.fill(255, 0, 0); lfoot.stroke(2); lfoot.vertex(50, 275); lfoot.vertex(50, 325); //left foot lfoot.vertex(25, 325); lfoot.endShape(CLOSE); PShape rfoot = createShape(); rfoot.beginShape(); rfoot.fill(255, 0, 0); rfoot.stroke(2); rfoot.vertex(125, 275); rfoot.vertex(125, 325); //right foot rfoot.vertex(100, 325); rfoot.endShape(CLOSE); fill(255, 255, 225); PShape leye = createShape(ELLIPSE, 60, 70, 25, 15); // eye fill(0, 0, 0); PShape brow = createShape(LINE, 40, 70,65,50); // eyebrow fill(0, 0, 0); PShape lieye = createShape(ELLIPSE, 60, 70, 10, 8); //pupil PShape tail = createShape(); tail.beginShape(); tail.fill(255, 0, 0); tail.stroke(2); tail.vertex(160, 275); tail.vertex(230, 295); //tail tail.vertex(200, 300); tail.endShape(CLOSE); fill(0, 0, 0); PShape mouth = createShape(RECT, 2, 95, 20, 5, 8); //mouth dragon.addChild(neck); dragon.addChild(lwing); dragon.addChild(rwing); dragon.addChild(lfoot); dragon.addChild(rfoot); dragon.addChild(tail); dragon.addChild(body); dragon.addChild(head); dragon.addChild(leye); dragon.addChild(lieye); dragon.addChild(mouth); dragon.addChild(brow); dragon.scale(small); shape(dragon,dragonX,abs(dragonY-x)); } void mousePressed() //mouse click changes time of day { x=mouseX; y=mouseY; } void keyPressed() { if (key == 'f') { fill(red); ellipse(mouseX+600,mouseY+200,100,100); small= abs(small-.1); } }