//// Q2 template (3) Button one, two, three, four; Witch Manny = new Witch(); Monster Mike = new Monster(); Animal Zoro = new Animal(); Tree[] t= new Tree[5]; int score=0; float left=20, right=780, horizon=200, bottom=580; float xTreat=0, yTreat; float nearby=50; void setup() { size( 800, 600 ); horizon= height/3; one= new Button(); two= new Button(); three= new Button(); four= new Button(); // +++ FIX THE ABOVE CODE, AND REMOVE THE FOLLOWING CODE: two.y= one.y+40; three.y= two.y+40; four.y= three.y+40; } void draw() { scene(); action(); trees(); messages(); } void scene() { background( 120, 150, 200 ); // nite fill( 100,200,100 ); rect( 0, horizon, width, height-horizon ); // grass; fill(200,200,180); float xMoon=width/2, yMoon=horizon/2; if (abs(xMoon-Manny.x) < 50) fill(255,255,50); ellipse( xMoon,yMoon, 80,80 ); // moon // Buttons // Buttons one.show(); two.show(); three.show(); four.show(); } void trees() { } void action() { // Monster chases treat. // +++ // Witch rides broom (right to left). Manny.move(); Manny.show(); // Rabbit scoots around // +++ } void messages() { } //// EVENTS //// void mousePressed() { // +++ Click below horizon to create candy treat. // +++ } class Button { // PROPERTIES // float x=40, y=40, w=80, h=30; String name="Click here"; color c=color( 255, 200, 200 ); // CONSTRUCTORS // // +++ // METHODS // void show() { fill( c ); rect( x,y, w,h ); fill(0); textSize(16); text( name, x+10, y+20 ); } } class Witch { float x=600,y=100, dx; float w=40, h=80, hh=30; // body w&h, head height void show() { if (x<=0) return; float broom=y+h; // broom fill(255,100,0); ellipse( x,y, 25,hh ); // Orange face. fill(0); rect( x-w/2, y+hh/2, w, h ); triangle( x-10,y-hh/2, x+10,y-hh/2, x,y-45 ); // hat rect( x-20,y-15, 40,3 ); // brim fill(100,0,0); rect( x-60,broom, 120,3 ); // Brown broomstick triangle( x+50,broom, x+60,broom-12, x+60,broom+12 ); } void move() { } }// class Witch // class Monster { void move() { } void show() { } }// class Monster // class Animal { void move() { } void show() { } }// class Animal // class Tree { }