1 package erland.game.tetris;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import erland.game.*;
22 import erland.game.component.EComponentMode;
23 import erland.util.*;
24
25 import java.awt.*;
26 import java.applet.Applet;
27
28 public class TetrisApplet extends Applet implements GamePanelHandlerApplicationInterface, Runnable {
29 protected Thread animator;
30
31 public DisplayMode[] getDisplayModes() {
32 DisplayMode[] displayModes = new DisplayMode[] {
33 new DisplayMode(640,480,32,0),
34 new DisplayMode(640,480,16,0),
35 new DisplayMode(640,480,8,0)};
36 return displayModes;
37 }
38
39 public void initGames(GamePanelHandlerInterface handler) {
40 handler.addPanel("Singleplayer","Starting the game",new TetrisMain(new TetrisModelStandalone()));
41 handler.addPanel("Multiplayer","Starting the game",new TetrisMain(new TetrisModelNetworked(getDocumentBase().getHost(),"player","player")));
42 handler.cheatWord("erland");
43 }
44
45
46 public void init() {
47 }
48
49 public void start()
50 {
51 if(animator==null) {
52 animator= new Thread(this);
53 animator.start();
54 }
55 }
56 public void stop()
57 {
58 if((animator != null) && (animator.isAlive())) {
59 animator = null;
60 }
61 }
62 public void run() {
63 ParameterValueStorageExInterface storage = null;
64 String mayScript = getParameter("MAYSCRIPT");
65 if(mayScript!=null) {
66 storage = new ParameterStorageString(
67 new CookieStorage(this,"tetris"),
68 null);
69 }
70 ImageHandlerInterface imageHandler = new ImageHandlerForApplet(this,"images/tetris");
71 GamePanelHandlerForApplet handler = new GamePanelHandlerForApplet(this);
72 handler.setImageHandler(imageHandler);
73 handler.setStorage(storage);
74 EComponentMode.setAppletMode(true);
75 while(animator!=null) {
76 GamePanelHandler.run(this,handler);
77 }
78 }
79 }