xxxxxxxxxx
31
//In your sketch, create a function called drawCreature. It should render a simple creature consisting of a 150 x 50 pixel rectangle, with an eye and mouth at one end. (These eye and mouth features will help ensure that the creature is facing in the correct direction). I’m using a 3-pixel thick black line, and a white fill, but you don’t have to.
//You may find it helpful to use the rectMode(CENTER) command, though you are not required to do so. Here’s the rectMode() reference; and here’s a 2-minute demo video.
//Modify your function so that it takes three arguments, respectively: the (x,y) pixel location of the center of the creature, and a rotation angle (in radians), which will govern the amount that the creature is rotated about its center point.
//Call your function so that it draws three copies of the creature, at the locations shown in the red overlays above. The draw() function of your sketch should look exactly like the code shown below: nothing less, and nothing more. (You are not expected to draw the red overlay; that’s a “debug view” to clarify the task.)
var pfont;
function preload() {
pfont = loadFont('BethEllen-Regular.ttf');
}
function setup() {
createCanvas(400, 400);
textFont(pfont, 8);
}
function draw() {
background (220);
translate(15, 10);
for (i = 0; i < 7; i++) {
for (j = 0; j < 7; j++)
makeText(i * 55, j * 55);
}
function makeText(a, b, c, d){
text("i have no", a, b, 80, 80);
text("idea what", a, b + 12, 80, 80);
text("i'm doing", a, b + 24, 80, 80);
}
}