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 SpiderApp7 { 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 #7", 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 < 5000 ; line++) { // Do things with first spider if (line % 2 == 0) { tinCan.veer(sp1, line % 31, -1); sp1.turnRight(); } else { tinCan.veer(sp1, line % 31, 1); sp1.turnLeft(); } if (line % 32 == 0) ++offset1; if (tinCan.isAtWall(sp1)) tinCan.jumpTo(sp1, line % (WIDE - 10), line % (HIGH - 10)); if (line % 256 == 0) sp1.setSilk(new Color(offset1 % 256, offset1 * 3 % 256, offset1 * 5 % 256)); // Do things with second spider tinCan.veer(sp2, line % 301, -3); 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;