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 SpiderApp6 { 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 #6", 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 offset1 = 1; for (int line = 0; line < 26000 ; line++) { // Do things with first spider sp1.turnLeft(); if (line % 32 == 0) ++offset1; tinCan.veer(sp1, line % 31, line % 2); if (tinCan.isAtWall(sp1)) tinCan.jumpTo(sp1, line % (WIDE - 10), line % (HIGH - 10)); if (offset1 % 5 == 0) sp1.setSilk(new Color(line * offset1 % 256, line * 3 % 256, line * 5 % 256)); // Do things with second spider tinCan.veer(sp2, line % 32, line % 2); sp2.turnLeft(); if (tinCan.isAtWall(sp1)) { sp2.setSilk(new Color(line % 256, line * 2 % 256, line * 3 % 256)); tinCan.jumpTo(sp2, sp1.getXY()); } } // end of for-loop } // end definition of main method } // end definition of class;