Throughout the recent years during browsing, I have encountered several examples
of Applets with what I would consider a magnificent feat of architectureal
design. One of the examples most relevent to my situation is Burning Metal,
a car racing game.

I look at the Applet and see the extremely intricate loading functions ...
after that it transfers to a mode select (single player, multiplayer), and
from there the game, victory animations, and high score entry.

My problem is that while I can easily write an Applet to do any given stage
of the above game, I am having trouble combining them to form the game as
a whole.

The Applet (not application) that I am writing will consist of a loading
stage, a map selection stage, the game stage, and the victory/defeat stage,
where it will promptly loop back to the map selection stage. It is to be
a VERY complex game with professional-quality user interface and graphics.
On the side, I plan to release the complete and well-documented source code
for other people who have encountered the countless problems I have as well
as the ones I am sure to face in the future.

Previously, for something like this, I would have an INTEGER value called
Mode (private int mode) that utilizes several FINAL INTEGERS to determine
which stage of the game I am on. An example for the simplified structure
I listed above would be:

private int mode;
private static final int GAME_LOADING = 1;
private static final int GAME_MAPSELECTION = 2;
private static final int GAME_PLAYING = 3;
private static final int GAME_OVER = 4;

And I would proceed to have a Paint function that used a case statement to
run specific paint routines as follows:

public void paint(Graphics g) {
switch(mode) {
paintLoading(g); break;
paintMapSelection(g); break;
etc. ... if you don't get the point by now, you can't help me =] (j/k!)

The problem is that while that worked, I encountered several programming
complexities when I implemented user interaction...

public void KeyTyped(KeyEvent e) {
switch(mode) {

The same occured for MouseDown (or whatever the MouseListener function is

Keep in mind that I will NOT use any of the AWT or Swing classes for graphics
and implementation reasons.

Looking back at previous programs I have written using the above method,
I see a very poorly-coded mess that would be extremely difficult for any
programmer but me to quickly sort out. In other words, I am unsatisfied
with this method AND I don't think it will apply to a complex game like I
am planning.

And so I am lost as to how to structure the program. The two methods I can
think of either use the "Mode-Case" method listed above, or rely solely on
user input on buttons to change the modes by adding different components
to the frame whose "mode" I would have changed...

Other game source codes I have seen use the "Mode-Case" method as well, and
that is a shame because I find it insufficient for the complexity if my game.

Then I see professional games like "Starcraft" and "Halflife" and KNOW that
they didn't use Modes! I'm not trying to make something up to their level,
but certainly it would be nice to know exactly how they implemented their
initial menu and game interface using the "public static void main" or, in
my case, the "public class <game> extends java.applet.Applet"...

Thank you in advance for any help or light you can shine on my situation...
I have even considered e-mailing some of the lesser game companies (the
more friendly ones) to ask how something like this can be implenented...
but I don't expect much success there.