Seeker s; void setup() { size(250, 250); s = new Seeker(); mouseX = width/2; mouseY = height/2; } void draw() { background(200); s.move(mouseX, mouseY); s.draw(); } class Seeker { float x, y, angle, sz; Seeker() { x = width / 2; y = height / 2; sz = width / 20; } float TURNSPEED = .1; float SPEED = 1; void move(float tx, float ty) { float dx = (tx -x); float dy = (ty - y); float wantangle = atan2(dy, dx); float anglediff = (angle - wantangle); //normalize things so the difference is between -PI and PI... if (anglediff > PI) { anglediff -= TWO_PI; } if (anglediff < -PI) { anglediff += TWO_PI; } if (anglediff > TURNSPEED) { angle -= TURNSPEED; } if (anglediff < -TURNSPEED) { angle += TURNSPEED; } x += cos(angle) * SPEED; y += sin(angle) * SPEED; } void draw() { ellipse(x, y, sz, sz); line(x, y, x + sz*cos(angle), y + sz * sin(angle)); } }