I am trying to draw a town. I have the pic of one house drawn. I need to be able to write a code to copy that picture and multiply it at different coordinates and different sizes. I have the code for the one house written, but I can't figure out how to multiply it. (Pic attached of example) I'm using DrJava.
My code for the house is:
My code for the house is:
Code:
public void drawHouse() {
//get graphics
Graphics graphics = this.getGraphics();
//start with black color
graphics.setColor(Color.blue);
//draw a filled rectangle
graphics.fillRect(10,210,200,100);
//set color back to black
graphics.setColor(Color.black);
//draw triangle
Polygon poly = new Polygon();
poly.addPoint(10, 210);
poly.addPoint(110, 50);
poly.addPoint(210, 210);
graphics.fillPolygon(poly);
//draw windows with yellow
graphics.setColor(Color.yellow);
graphics.fillRect(20,220,50,45);
graphics.fillRect(150,220,50,45);
//oval window
graphics.fillOval(85,150,50,45);
//draw door with black
graphics.setColor(Color.black);
graphics.fillRect(85,220,50,90);
Comment