import java.awt.*; /** Experimenting with two Spiders in a Room named "tinCan" --- click on the "close button" (marked X) in the top right corner of the spider's window, to terminate the application. @see Spider @see Room @see AppFrame @author Istvan Mohos, 1996 */ public class SpiderApp1 { static final int WIDE = 500; // window width, in pixels static final int HIGH = 430; // window height, in pixels public static void main(String[] args) { Room tinCan = new Room(); new AppFrame("In a tin can #1", tinCan, WIDE, HIGH); Spider sp1 = new Spider(90, 90, Room.WEST, Color.yellow, Color.red); Spider sp2 = new Spider(40, 40, Room.EAST, Color.blue, Color.blue); int offset = 1; for (int line = 0; line < 3200 ; line++) { // sp2 only tinCan.veer(sp2, line % 401, 1); sp2.turnLeft(); if (tinCan.isAtWall(sp2)) { tinCan.jumpTo(sp2, 90, 90); } } for (int line = 0; line < 3200 ; line++) { // sp1 only if ((line % 2) == 0) { tinCan.veer(sp1, line % 31, -1); sp1.turnRight(); } else { tinCan.veer(sp1, line % 31, 1); sp1.turnLeft(); } if (tinCan.isAtWall(sp1)) { tinCan.jumpTo(sp1, line % (WIDE - 10), line % (HIGH - 10)); tinCan.showMe(sp1); } if (line % 32 == 0) ++offset; if ((line % 256) == 0) { sp1.setSilk(new Color(offset % 256, offset * 3 % 256, offset * 5 % 256)); tinCan.showMe(sp1); } } // end of for-loop } // end definition of main method } // end definition of class;