We met Neko in the in-class exercises on Swing and Animation. I am told that "Neko" is Japanese for cat. Here it refers to a small animation written and drawn for the Macintosh by Kenji Gotoh in 1989. Since then, many people have worked on similar programs for all sorts of platforms. The rendition you see here is based on a version that appeared with "Teach Yourself Java in 21 Days" by Laura Lemay and Charles Perkins. I have added some randomization. The idea for putting several Nekos together as separate threads for a "cat race" originates with James Leutz, who worked on it as a final project for a class at Oberlin College in the Fall semester 1997.
Here is the Neko applet from Lemay and Perkins:
And here is the Java code. The images can be found at awake.gif, right2.gif, scratch2.gif, sleep2.gif, yawn.gif, right1.gif, scratch1.gif, sleep1.gif, stop.gif.
Just to familiarize yourself with the Neko code, try to put the
animation into an infinite loop. The cat should repeatedly do its
thing from left to right until you kill the window.
The cat code is pretty boring. It always runs to exactly half the width, stops, pauses yawns, scratches exactly four times, sleeps for exactly 5 units, and then runs the rest of the way at the same speed as its first spurt.