import java.util.*; import java.awt.*; // // Puzzle pushing .. // // 9 puzzle part // public class object80 extends object{ int state=0; int o1=0; int i1=0; public object80(){ objnumber=80; methods[0]="hit"; methods[1]="action1"; methods[2]="action3"; methods[3]="action4"; methods[4]="aftermoves"; methods[5]="event"; methods[6]="resetevent"; } public void init(Global glbl){ global=glbl; super.init(global); general=new General(global,getNr()); } public void execute(){ if(method.compareTo("action1")==0) action1(); if(method.compareTo("action3")==0) action3(); if(method.compareTo("action4")==0) action4(); if(method.compareTo("event")==0) event(); if(method.compareTo("hit")==0){ hit(); return; } if(method.compareTo("aftermoves")==0){ aftermoves(); } } public void aftermoves(){ //System.out.println("Checking 80 objects"); int r=global.grid.next(0,0,80); if(r<0)return; //System.out.println("Found 80"); // Check if the pieces are OK if(global.grid.get(r+(1*global.STEPP))==81) if(global.grid.get(r+(2*global.STEPP)) == 82) if( global.grid.get(r+((global.WIDTH*global.STEPP)*global.STEPP))==83) if(global.grid.get(r+((global.WIDTH*global.STEPP)*global.STEPP)+(1*global.STEPP))==84) if(global.grid.get(r+((global.WIDTH*global.STEPP)*global.STEPP)+(2*global.STEPP))==85) if(global.grid.get(r+((2*global.WIDTH*global.STEPP)*global.STEPP))==86) if(global.grid.get(r+((2*global.WIDTH*global.STEPP)*global.STEPP)+(1*global.STEPP))==87) if(global.grid.get(r+((2*global.WIDTH*global.STEPP)*global.STEPP)+(2*global.STEPP))==88){ //System.out.println("MATCHING NUMBER 80s"); for(int rr=0; rr<9;rr++){ r=global.grid.next(0,0,80+rr); if(r > -1) global.grid.set(r,1); } r=global.grid.next(0,0,89); global.grid.set(r,1); global.boardrow=-1; global.boardcol=-1; global.boardwidth=-1; global.boardheight=-1; global.doboard=true; } } public void hit(){ i1=general.getImageBehind(); int x,y; x=global.player.getX(); y=global.player.getY(); global.grid.setxy(x,y,objnumber); if(global.dir == -global.STEPP){ global.player.set(x-global.STEPP, y); global.grid.setxy(x-global.STEPP, y,i1); } // Right if(global.dir == global.STEPP){ global.player.set(x+global.STEPP, y); global.grid.setxy(x+global.STEPP, y,i1); } // down if(global.dir == global.STEPP*global.WIDTH){ global.player.set(x, y+global.STEPP); global.grid.setxy(x, y+global.STEPP,i1); } // up if(global.dir == -global.STEPP*global.WIDTH){ global.player.set(x, y-global.STEPP); global.grid.setxy(x, y-(global.STEPP),i1); } if(global.playsound && sound!=null) sound.play(); global.freeze=false; global.PLAYERSTATE=0; global.aftermoves=true; global.boardrow=-1; global.boardcol=-1; global.doboard=true; state=43; } // Action methods // Action methods public void action3(){ } public void action4(){ } public void action1(){ state=1; } // Action methods public void event1(){ if(general != null) state=general.push(state); } public void event2(){ global.freeze=false; global.resetevent=true; global.waitforme=false; global.aftermoves=true; global.State=global.NOTHING; state=3; } public void event(){ // put everything here like a 'run' method switch(state){ case 1: event1(); break; case 2: event2();break; } aftermoves(); } public void resetevent(){ if(global.perform) if(global.STEPP==1) state=0; else state=1; } }