import java.util.*; import java.awt.*; // // // Switch the directional object // // // public class object98 extends object{ Image img; public object98(){ objnumber=98; methods[0]="hit"; } public void init(Global glbl){ global=glbl; image=global.loadImage(global.Server,global.Directory+"98"+global.Extention,global.show); img=global.loadImage(global.Server, global.Directory+"175_1"+global.Extention, global.show); sound=global.loadSound(global.Server, global.Directory+"98.au"); } public void execute(){ if(method.compareTo("hit")==0){ hit(); return; } } // swap the direction public void hit(){ int x=global.player.getX(); int x1=x; int y=global.player.getY(); int y1=y; if(global.dir == -global.STEPP){ x-=global.STEPP; x1=x-global.STEPP; } // Right if(global.dir == global.STEPP){ x+=global.STEPP; x1=x+global.STEPP; } // down if(global.dir == global.STEPP*global.WIDTH){ y+=global.STEPP; y1=y+global.STEPP; } // up if(global.dir == -global.STEPP*global.WIDTH){ y-=global.STEPP; y1=y-global.STEPP; } int temp=global.grid.getxy(x1,y1); int s; System.out.println("object98 temp: "+temp+" x: "+x+" x1: "+x1); if(temp > 1 && temp != 13){ if(global.playsound)sound.play(); switch(temp){ case 4: // hole (was changed on background) case 3: // same but not needed or level53 // in Slow mode the background probably was changed .. so change it once more s=((y+global.STEPP)*global.WIDTH)+x; Image ig=global.loadImage(global.Server, global.Directory+temp+global.Extention, global.show); global.show.changeBackground(ig, s); s=((y1+global.STEPP)*global.WIDTH)+x1; global.show.changeBackground(img, s); break; } global.grid.setxy(x,y,temp); global.grid.setxy(x1,y1,98); } global.boardrow=-1; global.boardcol=-1; global.doboard=true; } }