import java.awt.*; public class object63 extends object1{ public Sound squick; public Image image2; public Image image1; public Image image; private Image image3; // 'Calculated'image private Image origbackground; public int other=-1; public int other2=-1; int cc=0; // Calculaged public object63(){ methods[0]="hit"; methods[1]="event1"; methods[2]="event2"; methods[3]="event"; methods[4]="resetevent"; objnumber=63; } // // Used to show the changed image // if we use parent image it will not show anything different // public Image getImage(){return image;} // Use super to use the parent methods public void init(Global glbl){ super.init(glbl); image1=global.loadImage(global.Server, global.Directory+"63"+global.Extention, global.show); image2=global.loadImage(global.Server, global.Directory+"63_1"+global.Extention, global.show); squick=global.loadSound(global.Server, global.Directory+"63.au"); image3=image1; // Make sure there is no image .. if there is an image it will 'ruin' the display // when we walk over it image=null; other=global.grid.next(0,0,62); other2=global.grid.next(0,0,getNr()); //System.out.println("GetBack: "+other2); // When used with background we have to calculate the offset it has // Our tile height is one greater than the location on screen! // if(global.STEPP == 1){ // other2+=(global.WIDTH*global.STEPP); // } if(other>-1){ origbackground=global.show.getBackground(other2); // global.show.drawImage(origbackground,300,300); int x,y; // // changeBackground uses different offsets .. so re-calculate other2: // extra complicated // AND HOW ABOUT CORNER ACTIVATIONS???? // /* if(global.STEPP==1) cc=other2; else{ //System.out.println("other2: "+other2); y=other2==0?0: (int) Math.floor((other2/(global.WIDTH*global.STEPP))/global.STEPP); //System.out.println("y = "+y); int t=((global.WIDTH*global.STEPP)*global.STEPP); int www=y*t; int ddd=other2-www; //System.out.println("(W*S)*S:"+t+" Y*t: "+(ddd)); //System.out.println("pos:"+pos+" - ("+ddd+") : "+ ddd+"needs to be divided by stepp(5)"); x=(ddd)/global.STEPP; cc=(y*(global.WIDTH*global.STEPP))+(x*global.STEPP)+global.WIDTH; } */ int yi=(other2==0?0:other2/(global.WIDTH*global.STEPP)); int xi=(other2%(global.WIDTH*global.STEPP)); int snr=((yi+global.STEPP)*global.WIDTH)+xi; cc=snr; //System.out.println("cc: "+cc); // global.show.changeBackground(image3,origbackground, cc); global.show.changeBackground(image3,origbackground, snr); } } public void execute(){ if(method.compareTo("hit")==0) hit(); if(method.compareTo("event")==0) event(); if(method.compareTo("resetevent")==0) resetevent(); } public void hit(){ super.hit(); if(other > -1){ if(global.playsound) squick.play(); if(global.grid.get(other)==62){ image3=image2; global.grid.set(other,1); } else if(global.grid.get(other)==1){ image3=image1; global.grid.set(other,62); } global.show.changeBackground(image3,origbackground, cc); global.boardrow=-1; global.boardcol=-1; global.boardwidth=-1; global.boardheight=-1; global.doboard=true; } } public void resetevent(){ super.resetevent(); } public void event(){ switch(state){ case 1:event1();break; case 2:event2();break; } } }