import java.awt.*; import java.lang.reflect.*; public class Start{ // 'Global' variables int MAXOBJECT=2000; // maximum of objects (object1-2000) int MAXLISTS=2000; // Maximum of lists int sleeper=25; // Plugin = 25 / < 1.1 55 //int WIDTH=22; // Width + Height will be calculated //int HEIGHT=16; int WIDTH=16; // Width + Height will be calculated int HEIGHT=11; int level=1; // which level int room=1; // which room (teamplay) int nroflevels=99; // Maximum nr of levels int usernr=10000; // Usernumber int team=usernr; // teamnumber -> Teamplay int State=0; // Game state boolean standalone=false; // Used when not connected to internet (future?) boolean debug=true; boolean transparent=false; // Transparency drawing boolean freeze=false; // You are HIT or catched or whatever you have to STOP! boolean doboard=false; // should we draw the board? boolean doreload=false; // HIT/DROWN/FALL etcc boolean dorotate=false; // Move of buckets boolean keyaction=false; // Is there an action going on? boolean gridloaded=false; // Is the grid loaded? int boardnr=-1; // what is the drawing board mechanism? int boardrow=-1; // Row int boardcol=-1; // Col int slider=0; // Loadingslider String javaversion=new String("1.0"); int all_aftermoves[]=new int[MAXOBJECT]; int all_aftermoves_nr=0; int all_events[]=new int[MAXOBJECT]; int all_events_nr=0; int all_resets[]=new int[MAXOBJECT]; int all_resets_nr=0; Grid grid; int grid_items[][]=new int[HEIGHT+1][WIDTH+1]; Player player; Loader loader; Object dynamic; Image background; // Background image FIFO ReadStack; // communication TeamPlay FIFO WriteStack; FIFO AllMoves; int laststack=-1; int PlayerPos=0; int oldPlayerPos=32; int pushed=0; // pushed position int dir=1; // Initialize the direction of movement String Server=new String(""); // Will be dynamicly fed by Show String Directory=new String("/maze/"); String Extention=new String(".gif"); Show show; // Handle communication to show screen // Game States !!! static final int INITIALIZE = 1; static final int CHANGE = 2; static final int STOP = 3; static final int LOAD = 4; static final int RUN = 5; static final int LOADING=6; static final int RUNNING=7; static final int NOTHING = 8; static final int WALK = 9; static final int PUSH = 10; // Menu states static final int MENU1 = 100; static final int MENU_NOTOK = 101; static final int MENU_OK = 102; static final int MENU_FULL = 103; // If all the rooms are full static final int MULTI = 104; // multiplay menu // internal variables // debug retrieve/sent int retrieved=0; int sent=0; int sbacky=0; int rbacky=0; // // METHODS // // Constructor // public Start(Show shw){ show=shw; grid=new Grid(this); player=new Player(this); loader=new Loader(this); WriteStack=new FIFO(); ReadStack=new FIFO(); AllMoves=new FIFO(); // Initialize clears(); } // // Clears the objects from memory // public void clears(){ int l; gridloaded=false; try{ l=Array.getLength(dynamic); for(int id=0; id < l; id++){ if(loader.isLoaded(id)){ System.out.println("Clearing object: "+id); Array.set(dynamic, id,null); } } }catch(Exception eg){ System.out.println(" Clearing error: "+eg.toString()); } // first remove all the objects if(dynamic != null)dynamic=null; grid.reset(); //System.out.println("Before Loader!"); // MAXIMUM OF LOADED OBJECTS try{ dynamic=(Object)Array.newInstance(Class.forName("oo"),MAXOBJECT); }catch(Exception e){ //System.out.println(" Exception in START: "+e.toString()); dynamic=null; } } public void init(){ if(dynamic==null)return; System.out.println(" Start-init"); System.out.println("TO BE DONE"); System.out.println("READ THE LEVEL FROM THE PLAER!"); System.out.println("Has level own images???"); Directory="/maze/level"+level+"/"; show.image[1]=show.loadImage(Server, Directory+"1"+Extention,show); // No own images ... default directory if(show.image[1]==null){ Directory="/maze/"; } grid.load("level"+level); for(int h=0; h 0){ oo o=(oo)loader.getObject(grid_items[h][w]); checkaction(o,grid_items[h][w]); slider++; } } show.repaint(); // show load-screen } // draw the board == > tell Show to launch it ;-) boardnr=-1; doboard=true; } // // Key action public void key(int d){ int o1=0; dir=d; //moveplayer // ! try{ o1=grid.get(player.get()+dir); }catch(Exception eg){ o1=-1; } if(o1==-1){ System.out.println("You hit a border!"); }else{ try{ oo o=(oo)loader.getObject(o1); o.setMethod("hit"); o.execute(); }catch(Exception e){} } // check if we have to do anything after the move aftermoves(); } // // Initialize all the objects public void inits(){ int t; int r; int s; String obj; int l; doreload=false; doboard=false; dorotate=false; try{ l=Array.getLength(dynamic); for(s=1; s< l; s++){ slider++; // for load screen if(loader.isLoaded(s)){ System.out.println( "Invoking method INIT on object: "+s); oo o=(oo)loader.getObject(s); o.init(this); } } }catch(Exception e){ System.out.println("INITS error: "+e.toString()); } keyaction=false; } // // ALL objects needs to be resetted (if they are in list!) // public void resets(){ int t; int r; int s; String obj; doreload=false; doboard=false; dorotate=false; for(int i=0;i