1 package erland.game.tileadventure;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import erland.game.GamePanelHandlerInterface;
22 import erland.game.GamePanelHandlerForApplet;
23 import erland.game.GamePanelHandler;
24 import erland.game.GamePanelHandlerApplicationInterface;
25 import erland.game.tileadventure.isodiamond.IsoDiamondBlockContainerData;
26 import erland.game.tileadventure.isodiamond.IsoDiamondDrawMap;
27 import erland.game.tileadventure.rect.RectBlockContainerData;
28 import erland.game.tileadventure.rect.RectDrawMap;
29 import erland.game.tileadventure.rect.RectEnvironment;
30 import erland.game.component.EComponentMode;
31 import erland.util.*;
32
33 import java.awt.*;
34 import java.applet.Applet;
35
36 /***
37 * This class implements the applet version of the game
38 */
39 public class TileAdventureApplet extends Applet implements GamePanelHandlerApplicationInterface, Runnable {
40 /*** Main thread in the applet */
41 protected Thread animator;
42
43 public DisplayMode[] getDisplayModes() {
44 DisplayMode[] displayModes = new DisplayMode[] {
45 new DisplayMode(640,480,32,0),
46 new DisplayMode(640,480,16,0),
47 new DisplayMode(640,480,8,0)};
48 return displayModes;
49 }
50
51 public void initGames(GamePanelHandlerInterface handler) {
52 handler.addPanel("Game","Starting the game",new TileAdventureMain(new TileAdventureModelStandalone()));
53 handler.cheatWord("erland");
54 }
55
56 public void start()
57 {
58 if(animator==null) {
59 animator= new Thread(this);
60 animator.start();
61 }
62 }
63
64 public void stop()
65 {
66 if((animator != null) && (animator.isAlive())) {
67 animator = null;
68 }
69 }
70
71 public void run() {
72 ParameterValueStorageExInterface storage = null;
73 String mayScript = getParameter("MAYSCRIPT");
74 if(mayScript!=null) {
75 storage = new ParameterStorageString(
76 new CookieStorage(this,"tileadventure"),
77 new JarFileStorage("TileAdventure.xml"),
78 "tileadventure");
79 }
80 ImageHandlerInterface imageHandler = new ImageHandlerForApplet(this,"images");
81 GamePanelHandlerForApplet handler = new GamePanelHandlerForApplet(this);
82 handler.setImageHandler(imageHandler);
83 handler.setStorage(storage);
84 handler.setCustomEnvironment(new RectEnvironment(handler));
85 EComponentMode.setAppletMode(true);
86 while(animator!=null) {
87 GamePanelHandler.run(this,handler);
88 }
89 }
90 }