class House { // fields float x, y, xDist, yDist; color hColor, rColor, cColor; // constructor House(float userX, float userY, float userWidth, float userHeight) { x = userX; y = userY; xDist = userWidth; yDist = userHeight; hColor = color(random(256), random(256), random(256)); rColor = color(random(256), random(256), random(256)); cColor = color(random(256), random(256), random(256)); } // methods void drawHouse( ) { //draw frame of house fill(hColor); rect(x,y,xDist,yDist); //draw roof fill(rColor); triangle(x-(xDist/15), y, x + (xDist/2), y - (yDist/1.5), x + xDist + (xDist/15), y); //draw window 1 fill(#FEFF00); rect(x + (xDist*.2), y + (yDist*.55), (xDist*.25), (yDist*.3)); //draw window panes fill(#000000); rect(x + (xDist*.2), y + (yDist*.7), (xDist*.25), (yDist*.001)); fill(#000000); rect(x + (xDist*.32), y + (yDist*.55), (xDist*.001), (yDist*.3)); //draw window 2 fill(#FEFF00); rect(x + (xDist*.2), y + (yDist*.1), (xDist*.25), (yDist*.3)); //draw window panes fill(#000000); rect(x + (xDist*.2), y + (yDist*.25), (xDist*.25), (yDist*.001)); fill(#000000); rect(x + (xDist*.32), y + (yDist*.1), (xDist*.001), (yDist*.3)); //draw window 3 fill(#FEFF00); rect(x + (xDist*.6), y + (yDist*.1), (xDist*.25), (yDist*.3)); //draw window panes fill(#000000); rect(x + (xDist*.6), y + (yDist*.25), (xDist*.25), (yDist*.001)); fill(#000000); rect(x + (xDist*.72), y + (yDist*.1), (xDist*.001), (yDist*.3)); //draw door fill(cColor); rect(x + (xDist*.6), y + (yDist*.55), (xDist*.25), (yDist*.45)); //draw doorknob fill(hColor); ellipse(x+(xDist*.8), y +(yDist*.8), (xDist*.05), (yDist*.05)); //draw door window fill(#FEFF00); rect(x+(xDist*.65), y +(yDist*.6), (xDist*.15), (yDist*.08)); fill(#000000); rect(x+(xDist*.7),y +(yDist*.6), (xDist*.001), (yDist*.08)); rect(x+(xDist*.75),y +(yDist*.6), (xDist*.001), (yDist*.08)); //draw garage fill(hColor); rect(x+(xDist),y+ (yDist*.25),(xDist),(yDist*.75)); fill(rColor); triangle(x+(xDist), y+ (yDist*.25), x + (xDist)+ (xDist/2), y - (yDist/2), x + xDist +xDist, y+ (yDist*.25)); fill(cColor); rect(x+xDist+(xDist*.1),y+(yDist*.5),xDist*.8,yDist*.5); //draw garage window fill(#FEFF00); rect(x+ xDist + (xDist*.2), y +(yDist*.6), (xDist*.6), (yDist*.08)); fill(#000000); rect(x+ xDist+ (xDist*.7),y +(yDist*.6), (xDist*.001), (yDist*.08)); rect(x+xDist+ (xDist*.6),y +(yDist*.6), (xDist*.001), (yDist*.08)); rect(x+xDist+ (xDist*.5),y +(yDist*.6), (xDist*.001), (yDist*.08)); rect(x+xDist+ (xDist*.4),y +(yDist*.6), (xDist*.001), (yDist*.08)); rect(x+xDist+ (xDist*.3),y +(yDist*.6), (xDist*.001), (yDist*.08)); //draw xmas tree fill(#003300); triangle(x-(xDist/2), y+(yDist)-(yDist*.1),x-(xDist/5), y + (yDist)-(yDist*.1), x - (xDist/3), y); fill(#330000); rect(x-(xDist/2.5),y +(yDist*.9), (xDist*.1), (yDist*.1)); } void moveHouse() { x+=2; if (x > width ) { x = -1400; } } }