import java.util.*; import java.awt.*; // // Switch for bomb // public class object45 extends object{ public Sound bomb; public Image image2; public Image image1; public int other=-1; public object45(){ methods[0]="hit"; methods[1]="resetevent"; objnumber=45; } public void init(Global glbl){ global=glbl; if(image1==null){ image1=global.loadImage(global.Server, global.Directory+"45"+global.Extention, global.show); bomb=global.loadSound(global.Server, global.Directory+"45.au"); image=image1; image2=global.loadImage(global.Server, global.Directory+"45_1"+global.Extention, global.show); } image=image1; other=global.grid.next(0,0,46); } public void execute(){ if(method.compareTo("resetevent")==0)resetevent(); if(method.compareTo("hit")==0){ hit(); return; } } public void hit(){ other=global.grid.next(0,0,46); while(other > -1){ if(global.playsound) bomb.play(); if(global.grid.get(other)==46){ int x=global.player.getX(); int y=global.player.getY(); int s=(y*global.WIDTH)+x; // eliminate objects on dynamite and around global.grid.set(other,1); if(global.grid.get(other-global.STEPP) != 13)global.grid.set(other-global.STEPP,1); if(global.grid.get(other-((global.STEPP*global.WIDTH)*global.STEPP)) != 13)global.grid.set(other-((global.STEPP*global.WIDTH)*global.STEPP),1); if(global.grid.get(other+((global.STEPP*global.WIDTH)*global.STEPP)) != 13)global.grid.set(other+((global.STEPP*global.WIDTH)*global.STEPP),1); if(global.grid.get(other+global.STEPP) != 13)global.grid.set(other+global.STEPP,1); if(other-global.STEPP == s || other+global.STEPP == s || other+((global.STEPP*global.WIDTH)*global.STEPP) == s || other-((global.STEPP*global.WIDTH)*global.STEPP) == s) { global.setInfo("Get away!"); global.doreload=true; } image=image2; global.boardrow=-1; global.boardcol=-1; global.boardwidth=-1; global.boardheight=-1; global.doboard=true; } other=global.grid.next(0,0,46); } } public void resetevent(){ image=image1; } }