import java.util.*; import java.awt.*; // // Blow // public class object148 extends object{ int list[]=new int[1000]; int list3[]=new int[1000]; int list3nr=0; int listnr=0; boolean hit=false; boolean isrunning=false; boolean stored=false; private int state=1; private int eventnr=0; long oldtime=0l; private int ANIMATION=8; private Image imgs[]=new Image[ANIMATION+1]; private int imgloop=0; private int event1list=0; int list2nr =0; public object148(){ objnumber=148; methods[0]="hit"; methods[1]="reset"; methods[2]="event"; methods[3]="events1"; methods[4]="events2"; methods[5]="aftermove"; } public void init(Global glbl){ boolean found=false; global=glbl; image=global.loadImage(global.Server,global.Directory+"148"+global.Extention,global.show); sound=global.loadSound(global.Server, global.Directory+"150.au"); int nr=-1; listnr=0; nr=0; while(!found){ nr=global.grid.next(nr==0?0:nr%(global.WIDTH*global.STEPP), nr==0?0:nr/(global.WIDTH*global.STEPP),148); if(nr < 0) found=true; else{ // Add the position to the list list[listnr++]=nr; } nr++; } eventnr=1; list3nr=0; hit=false; isrunning=false; } public void execute(){ if(method.compareTo("aftermove")==0) aftermove(); if(method.compareTo("hit")==0) hit(); if(method.compareTo("reset")==0) reset(); if(method.compareTo("event1")==0) event1(); if(method.compareTo("event") == 0) event(); } public void event1(){ Date d=new Date(); if((long)(d.getTime()) < oldtime+800)return; oldtime=(long)d.getTime(); aftermove(); } public void hit(){ } public void aftermove(){ int eind=0; int e; int j; int z; if(isrunning)return; int k = global.player.getX()%(global.WIDTH*global.STEPP); // global.freeze=true; try{ isrunning=true; for(int i=0;i k-(global.WIDTH*global.STEPP*2) && list[i]%(global.STEPP*global.WIDTH) < k+(global.WIDTH*global.STEPP*2) ){ //System.out.println("Blower: "+list[i]); eind=(global.WIDTH*global.HEIGHT*global.STEPP*global.STEPP)- (( (global.WIDTH*global.STEPP)- ( list[i] % (global.WIDTH*global.STEPP) ) )); eind+=(global.WIDTH*global.STEPP); e=eind; for(j=e; j > list[i] ; j-=(global.WIDTH*global.STEPP)*global.STEPP ) { int jx=j%(global.WIDTH*global.STEPP); int jy=j==0?0:j/(global.WIDTH*global.STEPP); if(jx==global.player.getX() && jy==global.player.getY() ){ //System.out.println("MOVE PLAYER!: "+eind); if(global.playsound){ Date d=new Date(); if(d.getTime() % 1000 < 50) sound.play(); } global.player.set(eind%(global.WIDTH*global.STEPP),eind==0?0:eind/(global.WIDTH*global.STEPP)); hit=true; // eind-=(global.WIDTH*global.STEPP); } z=global.grid.get(j); //System.out.println("j = "+j +" object :"+z+"Player pos: "+global.player.getxy()+" * stepp: x"+global.player.getX()+",y::"+global.player.getY()); switch(z){ case 13: //iron / fence case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: case 170: case 171: case 172: case 173: case 174: case 175: eind=j-((global.WIDTH*global.STEPP)*global.STEPP); //System.out.println("Eind is : "+eind); break; case 1: case -1: case 0: case 4: //hole case 3: //water case 204: case 205: case 206: case 207: case 208: case 209: case 210: case 211: case 212: case 213: case 214: case 215: case 216: case 217: case 218: break; default: hit=true; // list3[list3nr++]=eind+z; global.grid.set(j,1); if(z>1 && z!=99) if(global.playsound){ Date d=new Date(); if(d.getTime() % 1000 < 50) sound.play(); } global.grid.set(eind,z); eind-=((global.WIDTH*global.STEPP)*global.STEPP); break; } // switch } // for every occurence along the blow-line } // is nearby? if(hit){ //fullscreen draw! stored=false; global.boardrow=-1; global.boardcol=-1; global.doboard=true; hit=false; } } // for each blower }catch(Exception g){} isrunning=false; global.freeze=false; } public void reset(){ listnr=0; state=1; stored=false; eventnr=1; list3nr=0; hit=false; isrunning=false; } public void event(){ // put everything here like a 'run' method switch(state){ case 1: event1(); break; } // draw image } }