/* Neko the Cat! Modification of Lemay's Neko in TYJ in 21 Days. I broke the program into two specific threads - Applet and NekoThread. All of the cat mainipulations are done in the attached thread. The interface is managed through the Applet. I added a new method called "moveNeko." This method does all of the cat drawing. */ import java.awt.Graphics; import java.awt.Image; import java.awt.Color; import java.awt.Rectangle; import java.applet.Applet; import NekoThread; public class Neko extends Applet { NekoThread nt; Image i; int x; int y; public void init() { setBackground(Color.white); nt = new NekoThread(this); nt.start(); } public void moveNeko(Image i, int x, int y) { Rectangle or= new Rectangle(this.x, this.y, 32, 32); // Old Rectangle Rectangle r= new Rectangle( x, y, 32, 32); r = r.union(or); this.x = x; this.y = y; this.i = i; // Draw the new cat repaint(r.x, r.y, r.width, r.height); } public void paint(Graphics g) { g.drawImage(i, x, y, this); } public void destroy() { nt.stop(); } }