// VARIABLES float x = 100; float y = 100; float angleDog = 0.0; float angleTail1 = 0.0; float angleTail2 = 0.0; float dogLength = 160; float tailLength = -10; // SETUP void setup() { size(500, 400); smooth(); } // DRAW USING FOLLOW1 EXAMPLE void draw() { background(#017E11); // grass green float dx = mouseX - x; float dy = mouseY - y; angleDog = atan2(dy, dx); x = mouseX - (cos(angleDog) * dogLength); y = mouseY - (sin(angleDog) * dogLength); // BONE follows mouse but doesn't rotate float boneEnd = 20; stroke (255); strokeWeight (10); line (mouseX, mouseY+20, mouseX, mouseY-20); // middle noStroke (); fill (255); ellipseMode (CENTER); ellipse (mouseX+10, mouseY+25, boneEnd, boneEnd); // bottom right ellipse (mouseX-10, mouseY+25, boneEnd, boneEnd); // bottom left ellipse (mouseX+10, mouseY-25, boneEnd, boneEnd); // top left ellipse (mouseX-10, mouseY-25, boneEnd, boneEnd); // top right dog (x, y, angleDog); // dog follow mouse/bone and rotates } // WAGGING TAIL USING ARM EXAMPLE void tail (float x, float y, float a) { translate(x, y); rotate(a); line(0, 0, tailLength, 0) ; } // DOG FUNCTION void dog (float x, float y, float a) { pushMatrix(); translate(x, y); rotate(a); // FEET fill (#762C00); ellipse (110, 20, 25, 25); // front left ellipse (110, -20, 25, 25); // front right ellipse (60, 20, 25, 25); // back left ellipse (60, -20, 25, 25); // back right // BODY fill (#893200); ellipse (80, 0, 100, 60); // TAIL stroke (#893200); strokeWeight (14); angleTail1 = (mouseX/float(width) - 0.5) * -PI; angleTail2 = (mouseY/float(height) - 0.5) * PI; pushMatrix(); translate (30, 0); tail (0, 0, angleTail1); tail (tailLength, 0, angleTail2); tail (tailLength, 0, angleTail1); tail (tailLength, 0, angleTail2); tail (tailLength, 0, angleTail1); popMatrix (); noStroke (); // HEAD fill (#983800); ellipse (135, 0, 50, 30); ellipse (120, 0, 40, 40); // NOSE fill (0); ellipse (160, 0, 15, 15); // EYES ellipse (130, 10, 8, 8); ellipse (130, -10, 8, 8); fill (255, 100); ellipse (132, 8, 3, 3); ellipse (132, -8, 3, 3); // EARS fill (#B74300); ellipse (120, 20, 30, 10); ellipse (120, -20, 30, 10); popMatrix(); }