Framework of a complex game...

admin

Administrator
Staff member
Throughout the recent years during browsing, I have encountered several examplesof Applets with what I would consider a magnificent feat of architecturealdesign. 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), andfrom there the game, victory animations, and high score entry.My problem is that while I can easily write an Applet to do any given stageof the above game, I am having trouble combining them to form the game asa whole.The Applet (not application) that I am writing will consist of a loadingstage, 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 bea VERY complex game with professional-quality user interface and graphics.On the side, I plan to release the complete and well-documented source codefor other people who have encountered the countless problems I have as wellas the ones I am sure to face in the future.Previously, for something like this, I would have an INTEGER value calledMode (private int mode) that utilizes several FINAL INTEGERS to determinewhich stage of the game I am on. An example for the simplified structureI 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 torun specific paint routines as follows:public void paint(Graphics g) {switch(mode) {case GAME_LOADING:paintLoading(g); break;case GAME_MAPSELECTION: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 programmingcomplexities when I implemented user interaction...public void KeyTyped(KeyEvent e) {switch(mode) {case GAME_LOADING:handleKeyLoading(e);etc.The same occured for MouseDown (or whatever the MouseListener function iscalled)...Keep in mind that I will NOT use any of the AWT or Swing classes for graphicsand 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 anyprogrammer but me to quickly sort out. In other words, I am unsatisfiedwith this method AND I don't think it will apply to a complex game like Iam planning.And so I am lost as to how to structure the program. The two methods I canthink of either use the "Mode-Case" method listed above, or rely solely onuser input on buttons to change the modes by adding different componentsto the frame whose "mode" I would have changed...Other game source codes I have seen use the "Mode-Case" method as well, andthat 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 thatthey 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 theirinitial menu and game interface using the "public static void main" or, inmy 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 (themore friendly ones) to ask how something like this can be implenented...but I don't expect much success there.
 
Back
Top