xxxxxxxxxx
24
function setup() {
createCanvas(400, 100);
}
function draw() {
background(220);
//draw first house
triangle(15, 0, 0, 15, 30, 15);
rect(0, 15, 30, 25);
rect(12, 30, 10, 10);
//draw second house
translate(50,0);
triangle(15, 0, 0, 15, 30, 15);
rect(0, 15, 30, 25);
rect(12, 30, 10, 10);
//draw second house
//notice how translate moves from the last translate!
translate(50,0);
triangle(15, 0, 0, 15, 30, 15);
rect(0, 15, 30, 25);
rect(12, 30, 10, 10);
//if you didn't use translate here, you
//would need new x co-ordinates for every house
}