Week6

http://www.halcyon.com/amalmin/java.html

Note: This weeks code won't run off the web. It attempts to load two graphic files from the current directory, which untrusted applets aren't allowed to do. Download the code and the two GIF files, compile it, and run it with the appletviewer if you want to see it work. In the future I hope to be able to inbed the graphics into one of the class files...

/*
 * Audin Malmin
 * 5-4-98
 * Java/OS week 5 or 6 (I've lost count).
 *
 * This week has seen less progress.  (I spent my main programming time camping...  :)
 * I've added preliminary Cathedral code.  Basically it will load and display 2 cathedral
 * files.  They are displayed at fixed positions in the "background"...
 *
 * Current layout (has-a relationships):
 *
 * ColonyApplet --+
 *                |
 *              Frame --+
 *                      |
 *                  DrawPanel --+--------+---------+---------------+---------+---------+
 *                              |        |         |               |         |         |
 *                           LocalDL RemoteDL   LocalCL        %RemoteCL PopupMenu PopupMenu
 *                            |   |    |   |     |  |            |    |
 *                           Dude |   Dude |     | CathUpdate*%  |  CathUpdate*%
 *                                |        |     |               |
 *                            DudeUpdate*  | Cathedral       Cathedral%
 *                                         |
 *                                    DudeUpdate*
 *
 * Key:		*: thread		%: Not yet implimented
 *
 * (is-a relationships):
 *
 * Panel -> DrawPanel
 *
 * Applet -> ColonyApplet
 *
 * Menu -> PopupMenu
 *
 * LocalDL -> RemoteDL
 *
 * LocalCL -> RemoteCL	(At least in the future)
 *
 * So basically, DrawPanel is the main program loop.  It sets everything up and
 * handles events.  DrawPanel contains two popup menus and two DudeList objects.
 *
 * LocalDL is kind of a mutant linked list container.  It does contain a linked list
 * of Dude objects.  In addition it contains a DudeUpdate object.
 *
 * RemoteDL is derived from LocalDL.  It is identical except for the fact that, in the future,
 * it RemoteDL will get it's movement, creation, and destruction information from the remote
 * machine.
 *
 * DudeUpdate is a thread.  It's job is to animate each of the Dudes.  Basically it
 * runs through the linked list on it's own (it gets a pointer to the "first" Dude
 * object), calling the Dude.move() function for each one.  The DudeUpdate constructor
 * also gets a pointer to the main DrawPanel object, so that it can get ahold of the
 * Graphics Context and the background color.
 *
 * LocalCL is another bastard linked list container.  It contains a list of Cathedral object.
 * RemoteCL will be derived from it; again adding a network interfact.
 *
 * Cathedral currently just contains an image.  In the future I plan to have it animate a
 * small string of images...  Cathedrals should be created based on the number of followers
 * each player has.  Their design will shift (toward more complicated, larger structures) as
 * the population grows in size and knowledge.
 *
 * So what does it all do???????????????
 *
 * * It compiles and runs.
 *
 * * Two cathedrals are created and displayed.
 *
 * * Left-clicking on the screen will create one red Dude directly under the mouse
 *   cursor, and one blue Dude will be created randomly somewhere else.
 *
 * * The Dudes (both red and blue) will move around the window, bouncing off the
 *   edges.
 *
 * * The Dudes will vary slightly in color.  (Ie: all red dudes are red, but some are
 *   brighter and some are darker.)
 *
 * * Right-clicking on an unoccupied section of screen you will get a popup menu
 *   with a list of acts you can perform on the general area.  These acts will have
 *   a circle of influance on which they will be active.  They will also most likely
 *   "taint" the area with an aura of fear.  (ie: the Dudes should try to stay away
 *   from these areas.)
 *
 * * Right-clicking in a small area around a Dude will give you a popup menu with both
 *   the normal options and acts you can inflict on the Dude itself.  The menu also
 *   gives you the Dude's number.  Currently the only working option is "Mutate", which
 *   causes the dude to double in size.
 *
 * * Right-clicking on a cathedral will try to identify the cathedral.  In the future it will
 *   bring up a menu with cathedral options.
 *
 * So what doesn't it do???
 *
 * * You can't currently kill a Dude.  This isn't hard to add, though.
 *
 * * There's a problem with erasing the first drawing of a Dude...so you get some
 *   fluff left over on the background.
 */
 

The source code, graphic 1, graphic 2.

The Live demo.


Audin Malmin