View Javadoc

1   package erland.game.tileadventure;
2   /*
3    * Copyright (C) 2004 Erland Isaksson (erland_i@hotmail.com)
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18   *
19   */
20  
21  import erland.game.GamePanelHandlerForApplication;
22  import erland.game.GamePanelHandlerApplicationInterface;
23  import erland.game.GamePanelHandler;
24  import erland.game.GamePanelHandlerInterface;
25  import erland.game.tileadventure.rect.RectBlockContainerData;
26  import erland.game.tileadventure.rect.RectDrawMap;
27  import erland.game.tileadventure.rect.RectEnvironment;
28  import erland.game.tileadventure.isodiamond.IsoDiamondBlockContainerData;
29  import erland.game.tileadventure.isodiamond.IsoDiamondDrawMap;
30  import erland.game.tileadventure.isodiamond.IsoDiamondEnvironment;
31  import erland.util.*;
32  
33  import java.awt.*;
34  
35  /***
36   * This is the main class for the client part of the adventure game
37   */
38  public class TileAdventure extends GamePanelHandlerForApplication implements GamePanelHandlerApplicationInterface {
39      public TileAdventure(String type) {
40          if(type!=null && type.equalsIgnoreCase("isodiamond")) {
41              setCustomEnvironment(new IsoDiamondEnvironment(this));
42          }else {
43              setCustomEnvironment(new RectEnvironment(this));
44          }
45      }
46      /***
47       * Main method that starts the game
48       * @param args hostname username
49       */
50      public static void main(String[] args) {
51          TileAdventure game = new TileAdventure(args.length>0?args[0]:null);
52          GamePanelHandler.run(game,game);
53          System.exit(-1);
54      }
55  
56      public DisplayMode[] getDisplayModes()
57      {
58          DisplayMode[] displayModes = new DisplayMode[] {
59              new DisplayMode(640,480,32,0),
60              new DisplayMode(640,480,16,0),
61              new DisplayMode(640,480,8,0)};
62          return displayModes;
63      }
64  
65      public void initGames(GamePanelHandlerInterface handler)
66      {
67          StorageInterface jarfile = new JarFileStorage("TileAdventure.xml");
68          StorageInterface file = new FileStorage("TileAdventure.xml");
69          setStorage(new ParameterStorageStringEx(file,jarfile,"tileadventure"));
70          setImageHandler(new ImageHandlerForApplicationJarFile(getScreenHandler().getContainer(),"images"));
71          handler.addPanel("Game","Starting the game",new TileAdventureMain(new TileAdventureModelStandalone()));
72          handler.addPanel("Room edit","Starting the room editor",new RoomMapEditor());
73          handler.addPanel("Tile edit","Starting the tile editor",new MapObjectEditor());
74          handler.addPanel("World edit","Starting the world editor",new WorldMapEditor());
75          handler.addPanel("Anim edit","Starting the animation editor",new AnimationEditor());
76          handler.cheatWord("erland");
77      }
78  }