Monster+code

int x = 200; int y = 200; int xspeed = 5; int yspeed = 5;

void setup { size(400, 400); background(5, 60, 90); stroke(200, 200, 20); } void draw { background(5, 60, 90); monster(x, y); follow(4); } void monster(int x, int y) { line(x, y, x, y+100); line(x, y+100, x-50, y+150); line(x, y+100, x+50, y+150); line(x-50, y+50, x+50, y+50); ellipse(x, y-30, 60, 60); line(x-15, y-40, x-10, y-30); line(x+15, y-30, x+20, y-40); } void moveX { x = x + xspeed; if (x > width) { xspeed = xspeed*-1; } else if (x < 0) { xspeed = xspeed*-1; } } void moveY { y = y + yspeed; if (y > height) { yspeed = yspeed*-1; } else if (y < 0) { yspeed = yspeed*-1; } } void chase { x = mouseX; y = mouseY; } void follow(int followSpeed) {

if (x < mouseX) { if ((x + followSpeed) < mouseX){ x = x + followSpeed; } else { x = mouseX; } } else if (x > mouseX) { if ((x - followSpeed) > mouseX) { x = x - followSpeed; } else { x = mouseX; } }

if (y < mouseY) { if ((y + followSpeed) < mouseY) { y = y + followSpeed; } else { y = mouseY; } } else if (y > mouseY) { if ((y - followSpeed) > mouseY) { y = y - followSpeed; } else { y = mouseY; } }

} void mousePressed { print("x:" + mouseX + ", y:" + mouseY + "\n"); background(5, 60, 90); monster(mouseX, mouseY); }