// // // // Show // // Display the stuff // // GUI of the Game // // import java.awt.*; import java.awt.image.*; import java.net.*; import java.io.*; import java.util.*; import java.awt.event.*; public class Show extends Panel implements Runnable, KeyListener, MouseListener, ActionListener, FocusListener{ int MAXHEIGHT=(int)(Toolkit.getDefaultToolkit().getScreenSize().height); int MAXWIDTH=(int)(Toolkit.getDefaultToolkit().getScreenSize().width); int framecounter=0; int oldframecounter=0; // Frames Per Second show public int storedcounter=0; private int levelintro=0; // Do we need to show help info? long keytime=0; FIFO keystack=new FIFO(); int oldx=-1; int oldy=-1; // Did we move a particular side? // int REFRESH_RATE = 1; int REFRESH_RATE = 11; // int REFRESH_RATE = 5; // int REFRESH_RATE = 25; HighResTimer timer; long frametime=0; long oldtime=-1000; long FRAMERATE=10; int backup[][]; int backupbasket[]=new int[10]; int backupplayerx=-1; int backupplayery=-1; int backuplevel=0; int undo[][]; int undobasket[]=new int[10]; int undoplayerx=-1; int undoplayery=-1; int undolevel=-1; int arrow=0; int k1=0; // keyboard entry long tijd=0 ; // check if we launch event int keycounter=0; boolean debug=false; boolean already=false; // used to identified if we are already walking/pushing ? boolean loading=true; // Are we in load-screen? animation during load boolean looping=false; // Are we in mainloop? boolean first=false; // first used in events .. int STARTX=0; // global coordinates on screen int STARTY=0; int SIZE=0; // default size will change with use of MAXHEIGHT // Maybe in the future we will use dynamic screens int WSIZE=0; // Width and Height of objects are different int HSIZE=0; int EVENTLOOP=0; // How many times we loop in run-loop before we launch events? //int EVENTLOOP=3; // How many times we loop in run-loop before we launch events? Date date=new Date(); // used for unique URL connections (otherwise it may be cached!) Date datum; long starttijd; long stoptijd; Global global; // In Between Class -> Communication class begin applet; // Applet which we use the canvas from Keyboard keyboard; boolean isKey=false; // Graphics variables (double buffered) Image offscreen=null; Image offscreenboard=null; Graphics graphics; Graphics graphicsboard; Image sidemenuimage; int sidemenu_x=700; int sidemenu_y=500; int sidemenu_w=200; TextField hidden; // used to catch keyboard entries from! // Hidden hidden; Image border; Image loadball; Image keysimage; // display the use of keys Image keysimage2; // display the use of keys Image targetimage; Image targetimage2; // load/.getImage()s Image intros[]=new Image[12]; // separate gifs int introcount=0; int introloop=0; int INTROLOOP=3; Image intro; // animaged gif Image imgrightsmall; Image imgleftsmall; Image imgupsmall; Image imgdownsmall; Image imgright; Image imgleft; Image imgup; Image imgdown; Image imgtest; Image imgslowest; Image imgslow; Image imgnormal; Image imgfast; Image imgteamplay; Image imgsingleplay; Image imgplaysound; Image imgnoplaysound; Image imgfastest; Image imgundo; Image imgescape; Image imgbackup; Image imgrestore; Image imgrestore_big; Image imgbackup_big; Image imgundo_big; //Image load; Image load[]=new Image[14]; int loadchange=0; // Images of objects Image image[]=new Image[2]; // Used to show the playerimages // user images Image user_front[][]=new Image[15][2]; Image user_back[][]=new Image[15][2]; Image user_left[][]=new Image[15][2]; Image user_right[][]=new Image[15][2]; int animationstep=-1; // Steps in animation int stepper=0; // inbetween animation int stepx; int stepy; int STEP=6; int step=Math.round(((SIZE*1)/(STEP+1))); // move speed Thread looper; // animation loops and main loop! Thread loader; // loads images and objects levels etc.. Network network; // Reads writestack and inserts into readstack Stacker stacker; Menu menu[]=new Menu[10]; boolean loaded=false; // are we loaded? // Keycodes --> Change when user wants AWDS - keys .. Implemented later! int UP=38; int DOWN=40; int RIGHT=39; int LEFT=37; int ESC=27; int BS=8; // Backspace int oldplayerx=-1; // old player position .. check if move has been done ! int oldplayery=-1; // Text used in game .. implement multi-langual later Image text[]=new Image[100]; // // ----- MENU // TextField chattext; //TextArea chat; java.awt.List chat; //TextArea info; java.awt.List info; java.awt.List fieldlist; java.awt.Label Level; ImageButton playsound; ImageButton allscores; ImageButton right; ImageButton left; ImageButton up; ImageButton down; ImageButton test; ImageButton slow; ImageButton slowest; ImageButton normal; ImageButton fast; ImageButton fastest; ImageButton teamplay; ImageButton singleplay; ImageButton undobutton; ImageButton escapebutton; ImageButton backupbutton; ImageButton restore; // Team Play ImageButton multibutton; Image multiimage; // obsolete by menu4 v //java.awt.List multilist; //Button MultiOK; // // Colors // Color backgroundcolor=new Color(0,60,0); Color menucolor=new Color(0,60,0); Color emailforeground=Color.black; Color passwordforeground=Color.black; Color createlabelcolor=Color.white; Color chattextforegroundcolor=new Color(0,255,0); Color chattextbackgroundcolor=new Color(0,60,0); Color chatforegroundcolor=new Color(0,200,0); Color chatbackgroundcolor=new Color(0,60,0); Color infoforegroundcolor=new Color(0,200,0); Color infobackgroundcolor=new Color(0,0,0); Color fieldlistforegroundcolor=new Color(0,200,0); Color fieldlistbackgroundcolor=new Color(0,60,0); // // CONSTRUCTOR // Show(begin appletje){ setVisible(false); applet=appletje; setLayout(null); // No layout manager so we can freely move applet.thread.first=true; // Data Store global=new Global(this); // // Setting GNOME settings // global.isturn=false; global.standalone=false; //global.isnetwork=false; // are we in teamplay? global.isnetwork=true; // are we in teamplay? global.UP=UP; global.DOWN=DOWN; global.RIGHT=RIGHT; global.LEFT=LEFT; // Focus-field used for keyboard access hidden=new TextField(); // hidden=new Hidden(global); hidden.addFocusListener(this); hidden.addKeyListener(this); // keyboard=new Keyboard(global); // hidden.addKeyListener(keyboard); hidden.setBounds(0,0,1,1); // Place it outside drawing so there is no little dot ;-) // -1,-1,-1,-1 // Does not work on 1.1 (netscape 4.79) on Solaris hidden.requestFocus(); add(hidden); // Current directory (both server and standalone) global.Server=applet.getCodeBase().toString(); global.javaversion=System.getProperty("java.version") ; //global.osname=System.getProperty("os.name"); global.osname=System.getProperty("file.separator"); System.out.println("JAVA VERSION : "+global.javaversion); System.out.println("OS NAME: "+global.osname); if(global.osname.indexOf("/") > 0 || global.osname.indexOf("|") > -0 || global.osname.equals("/")){ System.out.println("Unix / MAC"); global.CHATSIZE=(int)(12); global.CHATLINESIZE=3*global.CHATSIZE; }else{ global.CHATSIZE=12; global.CHATLINESIZE=2*global.CHATSIZE; } global.textfont=new Font("Terminal", Font.BOLD, global.CHATSIZE); backup=new int[global.HEIGHT*10][global.WIDTH*10]; undo=new int[global.HEIGHT*10][global.WIDTH*10]; // Begin + progressionBar calculateds the new framerate //setSpeed(5,8,REFRESH_RATE); setSpeed(1,40,REFRESH_RATE); System.out.println("KEywait: "+global.KEYWAIT + " Framerate: "+FRAMERATE); // Set game state to LOAD --- game states are essential !!! global.State=global.LOAD; // Use mouselistener to get focus on hidden field so we can catch keyboard addMouseListener(this); // global the Threads .. use the global function // since this will ensure that it happens in an 1.1 applet global(); } // // Threads // public void global(){ // global threads <--- HERE AND NOT IN init() !!! if(looper == null){ looper = new Thread(this); looper.start(); looping=true; } // repaint(); loadImages(); // Get the images System.out.println("Setting menu1 "); global.State=global.MENU1; timer = new HighResTimer(); timer.setDelay(REFRESH_RATE); timer.setAutoCorrection(true, 10); timer.startTimer(); } // Default stop thread public void stop(){ if(looper != null){ looping=false; looper=null; } if(loader != null){ loading=false; loader=null; } } // Actions public void drawboard(){ board(0,0,global.WIDTH,global.HEIGHT); // draw the board global.State=global.RUNNING; } public void running(){ global.slider=0; int x=global.player.getX(); int y=global.player.getY(); hidden.requestFocus(); if(graphics != null){ graphics.setColor(backgroundcolor); graphics.fillRect(0,0,800,600); if(offscreenboard != null) graphics.drawImage(offscreenboard, STARTX,STARTY, this); } info.add("Usernr: "+global.usernr+"["+global.room+"]-"+global.team+""); global.State=global.NOTHING; } public void changing(){ menu(false); keystack.clear(); Next(); global.State=global.RUN; } public void doboard(){ if(global.doreload)return; //System.out.println("global.doboard is set to TRUE!"+global.boardrow+"col:"+global.boardcol); if(global.boardrow > -1 && global.boardcol > -1){ //System.out.println("boardrow: "+global.boardrow); //System.out.println("boardcol: "+global.boardcol); global.boardrow/=global.STEPP; global.boardcol/=global.STEPP; if(global.boardwidth==-1 || global.boardheight==-1){ board(global.boardrow, global.boardcol,global.PARTDRAW_WIDTH,global.PARTDRAW_HEIGHT ); }else{ board(global.boardrow, global.boardcol,global.boardwidth,global.boardheight); } } else{ System.out.println("Draw entire screen!"); board(0,0, global.WIDTH, global.HEIGHT); } //board(-1); // reset variables global.boardrow=-1; global.boardcol=-1; global.boardwidth=-1; global.boardheight=-1; global.doboard=false; } // This was for teamplay with corners .. obsoleted public void dorotate(){ global.dorotate=false; } // // RUN // // This is where all the logic is ;-) public void run(){ boolean done=false; int menuloop=0; int x=global.player.getX(); int y=global.player.getY(); long thetime; int tijd=0 ; // check if we launch event int pos, img, room; // little boards Thread.currentThread().setPriority(Thread.MAX_PRIORITY); // Thread.currentThread().setPriority(Thread.MIN_PRIORITY); long startTime = System.currentTimeMillis(); // Another trick to find out if we are looping // MAIN // ROUTINE // ----------------------------------------------------- while(Thread.currentThread() == looper ){ x=global.player.getX(); y=global.player.getY(); if(debug)System.out.println("Game state: "+global.State); if(global.State > (global.MENU-1) ){ loaded=true; applet.loaded=true; setVisible(true); } // if menu if(global.State < global.MENU1 ){ if(global.State == global.RUN ){ drawboard(); } if(global.State == global.RUNNING ){ System.out.println("Calling running"); running(); } // Stop the game! if(global.State == global.STOP) stop(); if(global.State == global.CHANGE) changing(); if(global.doboard){ System.out.println("We receive command to draw a board!"); doboard(); } if(global.dorotate) dorotate(); // if((global.State==global.WALK || global.State==global.PUSH) && !already){ // if(!already){ if(( global.State==global.PUSH) || global.State==global.WALK ){ already=true; board(y==0?0:y/global.STEPP, x==0?0:x/global.STEPP , global.PARTDRAW_WIDTH, global.PARTDRAW_HEIGHT); already=false; } // Execute the run method of every object // Get network stuff if(global.doreload){ setVisible(false); if(graphics != null){ graphics.setColor(backgroundcolor); graphics.fillRect(0,0,800,600); } applet.thread.first=true; global.freeze=true; global.dontwalk=true; global.State=global.RELOADING; reload(); global.doreload=false; } } // if STATE != Menu // } // if looping turned on? // // Draw the little boards // if(!global.AllMoves.isEmpty() && !global.standalone){ try{ String line=global.AllMoves.pop(); StringTokenizer sn=new StringTokenizer(line, ""+(char)17); pos=Integer.parseInt(sn.nextToken()); img=Integer.parseInt(sn.nextToken()); room=Integer.parseInt(sn.nextToken()); }catch(Exception eggs){} } // React on keys // BUT check it only on certain times! // Otherwise the animation sequence is not finished // and direction is changed during the animation // EVEN WHEN the global.freeze is true !!!! (?why?) date=new Date(); keytime=date.getTime(); if(debug) if(keytime-oldtime < global.KEYWAIT)System.out.println("Key wait!"); if(!keystack.isEmpty() && !global.resetevent && !global.freeze && (keytime - oldtime) > global.KEYWAIT){ global.resetevent=true; k1=Integer.parseInt(keystack.pop()); oldtime=keytime; if(k1 == UP) global.dir=-global.WIDTH*global.STEPP; if(k1 == DOWN) global.dir=global.WIDTH*global.STEPP; if(k1 == RIGHT) global.dir=global.STEPP; if(k1 == LEFT) global.dir=-global.STEPP; // keyboard reactions if(global.key(global.dir)) board(y==0?0:y/global.STEPP, x==0?0:x/global.STEPP , global.PARTDRAW_WIDTH, global.PARTDRAW_HEIGHT); } // tIME test if(global.level==1 && global.State < global.MENU1 && !global.keypressed){ if( (date.getTime() - global.playtime < (long)6000 ) && (date.getTime()-global.playtime)%1000 < 500){ board(0,0, global.WIDTH, global.HEIGHT ); } } // MAIN PAINT ROUTINE CALLED repaint(); if(timer !=null){ synchronized(timer) { try { timer.wait(); } catch(Exception e) {} } } } // while } // All run method from all objects // // EVENTS // // Change this so that it doesn't use eventlists .. let the objects handle it themselves! // public void events(){ String enr; int t,idx1,idx2,s; String obj; String tim; String str; int px,py; int r=0; int ti; t=0; for(int i=0;i (global.MENU-1) ){ for(menuloop=1; menuloop 1000){ frametime=date.getTime(); if(framecounter != oldframecounter){ oldframecounter=framecounter; framecounter=0; } } //graphicsboard.drawString(""+(oldframecounter),22,22); graphicsboard.drawString(""+(global.stap),22,22); //System.out.println("framecounter: "+framecounter); */ // PERFORM EVENTS events(); // Are we turnbased? if(global.isturn ){ // Is user active? if(global.turn>1){ global.freeze=false; // Only debug information!!! chattext.setText("-"); }else System.out.println("NOT ROOM"); // Debug information only } // OFFSCREEN DOUBLE BUFFER DISPLAY try{ if(global.gridloaded && offscreenboard !=null) g.drawImage( offscreenboard,STARTX,STARTY,this); else g.drawImage(offscreen, STARTX, STARTY, this); // double buffer }catch(Exception eeee){ System.out.println("Exception gridload drawing offscreenboard/offscreen"+eeee.toString()); } } // global.global.State < Menu else{ try{ g.drawImage(offscreen, STARTX, STARTY, this); // double buffer }catch(Exception eggeeg){ System.out.println(" offscreen drawing error exception in update: "+eggeeg.toString()); } } // state.menu }catch(Exception e){ //System.out.println("update catch error: "+e.toString()); } } public void paint(Graphics g){ update(g); } // // Load all the images AFTER the grid has load // public void loadImages(){ System.out.println("LOADING IMAGES"); System.out.println("LOADING IMAGES"); System.out.println("LOADING IMAGES"); System.out.println("LOADING IMAGES"); System.out.println("LOADING IMAGES"); System.out.println("LOADING IMAGES"); System.out.println("LOADING IMAGES"); System.out.println("LOADING IMAGES"); // level load before int g=0; int sizey=SIZE/2; // intro.gif is animated gif //intro=global.loadImage(global.Server,"images/intro.gif",this); for(int kk=0;kk<6;kk++) intros[kk]=global.loadImage(global.Server, "images/load"+kk+global.Extention, this); //load=global.loadImage(global.Server, "images/load.gif",this); multiimage=global.loadImage(global.Server, "images/multi.gif",this); imgslowest=global.loadImage(global.Server, "images/imgslowest.gif",this); imgslow=global.loadImage(global.Server, "images/imgslow.gif",this); imgnormal=global.loadImage(global.Server, "images/imgnormal.gif",this); imgfast=global.loadImage(global.Server, "images/imgfast.gif",this); imgteamplay=global.loadImage(global.Server, "images/imgteamplay.gif",this); imgsingleplay=global.loadImage(global.Server,"images/imgsingleplay.gif",this); imgfastest=global.loadImage(global.Server, "images/imgfastest.gif",this); imgescape=global.loadImage(global.Server, "images/imgescape.gif",this); imgundo=global.loadImage(global.Server, "images/undo.gif",this); imgundo_big=global.loadImage(global.Server, "images/undo_big.gif",this); imgbackup=global.loadImage(global.Server, "images/backup.gif",this); imgbackup_big=global.loadImage(global.Server, "images/backup_big.gif",this); imgrestore=global.loadImage(global.Server, "images/restore.gif",this); imgrestore_big=global.loadImage(global.Server, "images/restore_big.gif",this); imgplaysound=global.loadImage(global.Server, "images/sound.gif",this); imgnoplaysound=global.loadImage(global.Server, "images/nosound.gif",this); imgrightsmall=global.loadImage(global.Server, "images/imgrightsmall.gif",this); imgleftsmall=global.loadImage(global.Server, "images/imgleftsmall.gif",this); imgupsmall=global.loadImage(global.Server, "images/imgupsmall.gif",this); imgdownsmall=global.loadImage(global.Server, "images/imgdownsmall.gif",this); imgright=global.loadImage(global.Server, "images/imgright.gif",this); imgleft=global.loadImage(global.Server, "images/imgleft.gif",this); imgup=global.loadImage(global.Server, "images/imgup.gif",this); imgright=global.loadImage(global.Server, "images/imgright.gif",this); imgleft=global.loadImage(global.Server, "images/imgleft.gif",this); imgup=global.loadImage(global.Server, "images/imgup.gif",this); imgdown=global.loadImage(global.Server, "images/imgdown.gif",this); imgtest=global.loadImage(global.Server, "images/imgtest.gif",this); global.backgroundmusic=global.loadSound(global.Server, "/maze/00.au"); global.backgroundsound=global.loadSound(global.Server, "/maze/0.au"); global.backgroundsoundbase=global.backgroundsound; // global.level should be read in BEFORE so that we have the good level // global.Directory="/maze/level/"+(global.level)+"/"; if(debug)System.out.println("globalING LEVEL NUMBER: "+global.level); g=1; image[g]=global.loadImage(global.Server, global.Directory+g+global.Extention,this); if(image[g]==null){ global.Directory="/maze/"; } int kl=0; int kk=0; for(kl=0; kl<2;kl++) for(kk=0; kkglobal.WIDTH?4:5) *SIZE, (nrh==global.HEIGHT?nrh+1:5)*SIZE - (nrh==global.HEIGHT?0:r+nrh==global.HEIGHT+2?SIZE:(SIZE/2)) ); crop=createImage( (nrw==global.WIDTH?nrw+1:c+nrw>global.WIDTH?4:5) *SIZE, (nrh==global.HEIGHT?nrh+1:5)*SIZE - (nrh==global.HEIGHT?0:r+nrh==global.HEIGHT+2?SIZE:(SIZE/2)) ); if(crop!=null){ Graphics gr=crop.getGraphics(); if(offscreen_tmp != null){ gr.drawImage(offscreen_tmp,0, (nrh==global.HEIGHT?0:-SIZE),this); } }else{offscreen_tmp=null;} // PUT cropped image on the board if(graphicsboard!=null && crop != null){ graphicsboard.drawImage(crop,( nrw==global.WIDTH?w_start:(c>1?c-2:0))*SIZE,( (nrh==global.HEIGHT?r:(r>1?r-1:r==0?r+1:r)) *SIZE )+ssize,this); } // tIME test if(global.level==1 && !global.keypressed){ Date date=new Date(); long dd=(date.getTime() - global.playtime); if( (dd < 5000 ) ){ if( levelintro++ < 2){ // graphicsboard.drawImage(keysimage2, 30,35, this); graphicsboard.drawImage(keysimage, 160,135, this); graphicsboard.drawImage(targetimage2, 460,375, this); }else{ levelintro=1; graphicsboard.drawImage(keysimage, 160,135, this); graphicsboard.drawImage(targetimage, 460,375, this); } } } } // is there a graphics display if(nrw==global.WIDTH && applet.loaded ){ menu(true); applet.thread.first=true; setVisible(true); } } // OBSOLETED !! // Make image transparent // leave it in since we can use the pixelgrabber for other aspects maybe! public Image trans(Image bi) { int width = bi.getWidth( this); int height= bi.getHeight( this); int[] pgPixels = new int[height* width]; PixelGrabber pg = new PixelGrabber(bi, 0, 0, width, height, pgPixels, 0,width); try { pg.grabPixels(); } catch (InterruptedException e) { e.printStackTrace(); } // try for (int y = 0; y > 24; int r = (pgPixels[i] & 0x00ff0000) >> 16; int g = (pgPixels[i] & 0x0000ff00) >> 8; int b = pgPixels[i] & 0x000000ff; if (r >= 210 && g >= 0 && b >= 210) { a = 0; pgPixels[i] = a | (r << 16) | (g << 8) | b; } // if pink? } // for x } // for y Image _i = createImage(new MemoryImageSource(width, height, pgPixels, 0,width)); return _i; }//trans // // Next level! // public void Next(){ global.Directory="/maze/level"+(global.level+1)+"/"; int g=1; image[g]=global.loadImage(global.Server, global.Directory+g+global.Extention,this); if(image[g]==null){ global.Directory="/maze/"; image[g]=global.loadImage(global.Server, global.Directory+g+global.Extention,this); } // Close events and stuff global.resets(); // Clear objects global.clears(); // Re-Initialize objects global.inits(); // Next Level global.level++; global.init(); } public void reload(){ // Store before reload reloading(); } // // ESCape // public void reloading(){ setVisible(false); applet.thread.first=true; global.State = global.RELOADING ; global.gridloaded=false; keystack.clear(); global.bagreset(); global.resets(); // reload the grid global.grid.load("level"+global.level); global.inits(); global.State=global.RUN; } // ======================================= // Menu's // // public void sidemenu(){ // // Side Menu // int sizex=SIZE/2; int sizey=SIZE; int B=35;; chattext=new TextField(); chattext.setName("chattext"); chattext.setBounds((global.WIDTH*SIZE), 1*sizey, 7*sizex, global.CHATLINESIZE); chattext.setFont(global.textfont); chattext.addActionListener(this); chattext.addKeyListener(this); chattext.setVisible(false); if(debug)System.out.println("chattext.setVisible(flase!"); chattext.setBackground(chattextbackgroundcolor); chattext.setForeground(chattextforegroundcolor); add(chattext); chat=new java.awt.List(); chat.setName("chat"); chat.setFont(global.textfont); chat.setBackground(chatbackgroundcolor); chat.setForeground(chatforegroundcolor); chat.setBounds((global.WIDTH*SIZE), 2*sizey, 7*sizex, sizex*3); chat.setVisible(false); if(debug)System.out.println("chat.setVisible(flase!"); add(chat); info=new java.awt.List(); info.setBounds((global.WIDTH*SIZE), 3*sizey, 7*sizex, sizex*3); // info.addKeyListener(this); info.setFont(global.textfont); info.setName("info"); info.setBackground(infobackgroundcolor); info.setForeground(infoforegroundcolor); info.setVisible(false); if(debug)System.out.println("info.setVisible(flase!"); add(info); right=new ImageButton(imgright,"right",this,"Right"); right.setBounds((global.WIDTH*SIZE), 5*sizey, B, B); right.setVisible(false); right.addActionListener(this); add(right); left=new ImageButton(imgleft,"left",this, "Left"); left.setBounds((global.WIDTH*SIZE)+B*1, 5*sizey, B, B); left.setVisible(false); left.addActionListener(this); add(left); up=new ImageButton(imgup,"up",this, "Up"); up.setBounds((global.WIDTH*SIZE)+B*2, 5*sizey, B, B); up.setVisible(false); up.addActionListener(this); add(up); down=new ImageButton(imgdown,"down",this, "Down"); down.setBounds((global.WIDTH*SIZE)+B*3, 5*sizey, B, B); down.setVisible(false); down.addActionListener(this); add(down); test=new ImageButton(imgtest,"test",this, "Test"); test.setBounds((global.WIDTH*SIZE)+B*4, 5*sizey, B, B); test.setVisible(false); test.addActionListener(this); add(test); teamplay=new ImageButton(imgteamplay,"teamplay",this,"Team"); teamplay.setBounds((global.WIDTH*SIZE), 6*sizey, B, B); teamplay.setVisible(false); teamplay.addActionListener(this); add(teamplay); singleplay=new ImageButton(imgteamplay,"singleplay",this,"Single"); singleplay.setBounds((global.WIDTH*SIZE)+B, 6*sizey, B, B); singleplay.setVisible(false); singleplay.addActionListener(this); add(singleplay); fastest=new ImageButton(imgfastest,"fastest",this,"Fastest"); fastest.setBounds((global.WIDTH*SIZE)+B, 8*sizey, B, B); fastest.setVisible(false); fastest.addActionListener(this); add(fastest); normal=new ImageButton(imgnormal,"normal",this, "Regular"); normal.setBounds((global.WIDTH*SIZE)+(B*2), 8*sizey, B, B); normal.setVisible(false); normal.addActionListener(this); add(normal); // repaint(); undobutton=new ImageButton(imgundo,"undo",this,"Undo"); undobutton.setBounds((global.WIDTH*SIZE), 9*sizey,B, B); undobutton.setVisible(false); undobutton.addActionListener(this); add(undobutton); escapebutton=new ImageButton(imgescape,"escape",this,"Escape"); escapebutton.setBounds((global.WIDTH*SIZE), 7*sizey,B, B); escapebutton.setVisible(false); escapebutton.addActionListener(this); add(escapebutton); backupbutton=new ImageButton(imgbackup,"backup",this, "Backup"); backupbutton.setBounds((global.WIDTH*SIZE)+(B*2), 9*sizey,B, B); backupbutton.setVisible(false); backupbutton.addActionListener(this); add(backupbutton); restore=new ImageButton(imgrestore,"restore",this, "Restore"); restore.setBounds((global.WIDTH*SIZE)+(B*3), 9*sizey,B, B); restore.setVisible(false); restore.addActionListener(this); add(restore); playsound=new ImageButton(imgnoplaysound,"playsound",this, "Sound"); playsound.setBounds((global.WIDTH*SIZE),10*sizey,B, B); playsound.setVisible(false); playsound.addActionListener(this); add(playsound); fieldlist=new java.awt.List(); fieldlist.setName("fieldlist"); // fieldlist.addKeyListener(this); fieldlist.setBounds((global.WIDTH*SIZE), 12*sizey, 7*sizex, sizex*3); fieldlist.setVisible(false); if(debug)System.out.println("fieldlist.setVisible(flase!"); fieldlist.setFont(global.textfont); fieldlist.setBackground(fieldlistbackgroundcolor); fieldlist.setForeground(fieldlistforegroundcolor); add(fieldlist); fieldlist.addActionListener(this); // Not necesary for(int lvl=1; lvl -1)return; if(global.freeze || global.dontwalk)return; if(global.State > global.MENU1-1) return; if(global.State == global.RELOADING || global.State == global.CHANGE || global.State == global.LOADING) return; if(!global.keypressed){ global.keypressed=true; board(0,0,global.WIDTH,global.HEIGHT); // draw the board } k1=k.getKeyCode(); if(global.isturn && global.turn==0) return; //System.out.println("isturn is ok!"); if(k1 == UP || k1 == DOWN || k1 == LEFT || k1 == RIGHT){ for(int i=0;i -1){ // special commands if(chattext.getText().indexOf("!@!") > -1){ if(debug)System.out.println("Special action (debug?)"); }else{ if(debug)System.out.println("Add text to writestack!: "+chattext.getText()); String chat_text=URLEncoder.encode(chattext.getText()); global.WriteStack.push("-10"+(char)17+chat_text+(char)17+global.room+(char)18); // clear chatline chattext.setText(""); hidden.requestFocus(); } } if(ae.toString().indexOf("fieldlist") > -1){ // String s=ae.toString(); String s=ae.getActionCommand(); if(debug)System.out.println("ActionCommand: "+s); String t=s.substring(s.indexOf("Level ")+6); if(debug)System.out.println("Level: "+t); ij=Integer.parseInt(t); if(debug)System.out.println("Level : "+ij); menu(false); first=false; // reset event-route global.slider=0; global.level=ij-1; fieldlist.select(global.level-1); // Level.setText("Level: "+global.level); global.State=global.CHANGE; } if(ae.toString().indexOf("teamplay") > -1){ global.teamplay=false; menu(true); } if(ae.toString().indexOf("singleplay") > -1){ menu(false); first=false; // reset event-route global.slider=0; global.State=global.MENU_TEAM; } if(ae.toString().indexOf("fast") > -1){ //speed(3,13,10); setSpeed(3,13,10); } if(ae.toString().indexOf("fastest") > -1){ // speed(1,40,storedcounter); //speed(0,40,0); System.out.println("Fastest selected"); // speed(1,40,25); // setSpeed(1,40,11); setSpeed(1,40,11); } if(ae.toString().indexOf("normal") > -1){ //speed(4,10,20); //setSpeed(5,8,15); setSpeed(5,8,5); } if(ae.toString().indexOf("slow") > -1){ speed(5,8,40); } if(ae.toString().indexOf("slowest") > -1){ speed(5,8,60); } if(ae.toString().indexOf("escape") > -1 ){ escape(); } if(ae.toString().indexOf("undo") > -1 && undoplayerx > -1 && undolevel==global.level){ undo(); } if(ae.toString().indexOf("backup") > -1 ){ backup(); } if(ae.toString().indexOf("restore") > -1&& backupplayerx > -1 && global.level == backuplevel){ restore(); } if(ae.toString().indexOf("playsound") > -1){ if(global.playsound){ playsound.setImage(imgnoplaysound); global.playsound=false; global.backgroundsound.stop(); global.backgroundmusic.stop(); }else{ playsound.setImage(imgplaysound); global.playsound=true; global.backgroundsound=global.backgroundsoundbase; global.backgroundsound.loop(); global.backgroundmusic.loop(); } } if(ae.toString().indexOf("right") > -1){ arrow=1; System.out.println( "right"); } if(ae.toString().indexOf("left") > -1){ arrow=2; System.out.println( "left"); } if(ae.toString().indexOf("up") > -1){ arrow=3; System.out.println( "up"); } if(ae.toString().indexOf("down") > -1){ arrow=4; System.out.println( "down"); } if(ae.toString().indexOf("test") > -1){ System.out.println( "test"); } } public void focusGained(FocusEvent fe){} public void focusLost(FocusEvent fe){} public void backup(){ for(int i=0;i