int x = 40; int y = 100; int eyeSize = 16; float d, b; // Starting position of shape float xspeed = 2.8; // Speed of the shape float yspeed = 2.2; // Speed of the shape int xdirection = 1; // Left or Right int ydirection = 1; // Top to Bottom void setup () { size (400,200); smooth(); frameRate(30); } void draw () { background (255); move(); bounce(); drawZoog(); } void drawZoog () { rectMode(CENTER); //Body stroke(0); fill(175); rect(x+b,y+d,10,120); // Draw Zoog's head fill(255); ellipse(x+b,y-50+d,60,60); // Draw Zoog's eyes fill(0); ellipse ( x-15+b , y-50+d , eyeSize , eyeSize*2); ellipse ( x+15+b , y-50+d , eyeSize , eyeSize*2); // Draw Zoog's legs stroke (0); line ( x-5+b, y+60+d, x-15+b, y+75+d); line ( x+5+b, y+60+d, x+15+b, y +75+d); } void move() { b = b + ( xspeed * xdirection ); d = d + ( yspeed * ydirection ); } void bounce() { if (b-30 > width || b < 0) { xdirection *= -1; } if (d+30 > height || d < 0) { ydirection *= -1; } }