import java.util.*; import java.awt.*; public class object43 extends object{ int state=0; int i1=0; int o1=0; boolean matching=false; public object43(){ methods[0]="hit"; methods[1]="event"; methods[2]="event1"; methods[3]="action1"; methods[4]="resetevent"; objnumber=43; } public void init(Global glbl){ global=glbl; if(image == null){ image=global.loadImage(global.Server, global.Directory+"43"+global.Extention, global.show); sound=global.loadSound(global.Server, global.Directory+"43.au"); } if(global.grid.next(0,0,224) > -1){ matching=true;} general=new General(global,getNr()); state=0; } public void execute(){ if(method.compareTo("action1")==0) action1(); if(method.compareTo("event")==0) event(); if(method.compareTo("resetevent")==0) resetevent(); if(method.compareTo("event1")==0) event1(); if(method.compareTo("hit")==0){ hit(); return; } } public void hit(){ i1=general.getImageBehind(); o1=general.getBehind(); String l="action"+o1; if(o1 < 40){ if(is(l)){ setMethod(l); execute(); } }else{ if(o1 == objnumber){ makepuzzle(); } } } public void action1(){ state=1; } // Action methods public void event1(){ if(general != null) state=general.push(state); } public void makepuzzle(){ int nx=0; boolean play=false; int ny=0; int o=global.grid.next(0,0,objnumber); while( o > -1){ int nr=o; nx=nr%(global.WIDTH*global.STEPP); ny=nr/(global.WIDTH*global.STEPP); // 4 - block if( global.grid.getxy(nx+global.STEPP,ny) == objnumber && global.grid.getxy(nx,ny+global.STEPP) == objnumber && global.grid.getxy(nx+global.STEPP,ny+global.STEPP) == objnumber){ global.grid.setxy(nx+global.STEPP, ny, 1); global.grid.setxy(nx+global.STEPP, ny+global.STEPP, 1); global.grid.setxy(nx, ny+global.STEPP, 1); global.grid.setxy(nx, ny, 1); play=true; } if(!matching){ // horizontal if( global.grid.getxy(nx+global.STEPP,ny) == objnumber && global.grid.getxy(nx+(global.STEPP*2),ny) == objnumber && global.grid.getxy(nx+(global.STEPP*3),ny) == objnumber){ global.grid.setxy(nx, ny, 1); global.grid.setxy(nx+global.STEPP, ny, 1); global.grid.setxy(nx+(global.STEPP*2), ny, 1); global.grid.setxy(nx+(global.STEPP*3), ny, 1); play=true; } // vertical if( global.grid.getxy(nx,ny+global.STEPP) == objnumber && global.grid.getxy(nx,ny+(global.STEPP*2)) == objnumber && global.grid.getxy(nx,ny+(global.STEPP*3)) == objnumber){ global.grid.setxy(nx, ny, 1); global.grid.setxy(nx,ny+global.STEPP, 1); global.grid.setxy(nx,ny+(global.STEPP*2), 1); global.grid.setxy(nx,ny+(global.STEPP*3), 1); play=true; } } if(play){ if(global.playsound){ sound.play(); } } o=global.grid.next(nx+global.STEPP,ny,objnumber); } global.boardrow=-1; global.boardcol=-1; global.doboard=true; } 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; } } // public void resetevent(){ } }