/** a sheepcounter by Guru */ PImage sheep; PFont font; long sheepcounter = 0; int sposx; int sposy; void setup() { size(600,300); smooth(); sheep = loadImage( "sheep.png" ); font = loadFont("BitstreamVeraSans-48.vlw"); textFont( font, 48 ); sposx = -sheep.width; sposy = 200 - sheep.height; } void draw() { background(128,128,255); fill( color( 128, 255, 128 )); noStroke(); rect(0, 200, width, 100); fill( color( 128,100,0)); rect( width/2 + 30, 120, 20, 80 ); fill(0); textAlign(RIGHT); text( "" + sheepcounter, width - 60, 60 ); sposx+=2; if (sposx > width ) { sposx = -1 *sheep.width ; sheepcounter++; } if (sposx > width/2 - 100 && sposx < width/2 + 100) { sposy = int(100 - sheep.height + sq(float(sposx - width/2))/100); } image( sheep, sposx, sposy ); }