import java.util.*; import java.awt.*; // // Blow cloud -> right // public class object150 extends object{ long oldtime=0l; 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; private int ANIMATION=8; private Image imgs[]=new Image[ANIMATION+1]; private int imgloop=0; private int event1list=0; int list2nr =0; public object150(){ objnumber=150; 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+"150"+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),150); if(nr < 0) found=true; else{ // Add the position to the list list[listnr++]=nr; //System.out.println("object150 in pos: "+nr); } nr++; } eventnr=1; hit=false; isrunning=false; list3nr=0; } 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 x=global.player.getX(); int y=global.player.getY(); int k = y; // global.freeze=true; isrunning=true; try{ for(int i=0;i k-(global.STEPP*2) && li < k+(global.STEPP*2) ){ // --- why was this - - list[i]% ?? // eind=( ( li+1) *(global.WIDTH*global.STEPP)) - (( list[i] % (global.WIDTH*global.STEPP) )); //System.out.println("Blower TO THE RIGHT?: "+li+"list[i]"+list[i]+"Calculated eind +(width*stepp)"+eind); eind=((li+1) *(global.WIDTH*global.STEPP)) ; e=eind; for(j=e; j > list[i] ; j-=global.STEPP) { int jx=j%(global.WIDTH*global.STEPP); int jy=j==0?0:j/(global.WIDTH*global.STEPP); if(jx==x && jy==y ){ //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; } 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.STEPP; //System.out.println("Nieuwe 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; global.grid.set(j,1); if(z > 1 && z != 99) { //System.out.println("Blaas: "+z+"j:"+j); if(global.playsound){ Date d=new Date(); if(d.getTime() % 1000 < 50) sound.play(); } } global.grid.set(eind,z); eind-=global.STEPP; //System.out.println("Blowing object z: "+z+"New eind: "+eind); 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 eg){} isrunning=false; global.freeze=false; } public void reset(){ listnr=0; state=1; stored=false; eventnr=1; hit=false; isrunning=false; list3nr=0; } public void event(){ // put everything here like a 'run' method switch(state){ case 1: event1(); break; } // draw image } }