import java.util.*; import java.awt.*; // // End point of puzzle // // public class object196 extends object{ // calculate the random cards private static Random random = new Random(); int state=0; long oldtime=0; Image oldimage; // When card is turned it should be put back public object196(){ objnumber=196; methods[0]="hit"; methods[1]="resetevent"; methods[2]="event"; } public void init(Global glbl){ global=glbl; if(image == null){ image=global.loadImage(global.Server, global.Directory+"196"+global.Extention, global.show); oldimage=image; } sound=global.loadSound(global.Server, global.Directory+"99.au"); Date d=new Date(); oldtime=(long)d.getTime(); } public void execute(){ if(method.compareTo("event")==0) event(); if(method.compareTo("resetevent")==0) resetevent(); if(method.compareTo("hit")==0){ hit(); return; } } // Hit the crate/wood public void hit(){ int nr; boolean found=false; int pos[]=new int[16]; int pos2[]=new int[16]; int i=0; for(i=0; i < 16 ; i++){ pos[i]=global.grid.next(0,0,(180+i)); System.out.println("Location of : "+i+" ="+pos[i]); } // Compare it with the grid that should be made i=0; int j=0; pos2[0]=global.grid.next(0,0,180); System.out.println("Location of : "+i+" ="+pos2[0]); int x=1; for(x=1; x < 16; x++){ if(x%4==0)j++; pos2[x]=pos2[0]+(j*(global.STEPP*(global.STEPP*global.WIDTH)))+((x%4)*global.STEPP); System.out.println("Location of : "+x+" ="+pos2[x]); } x=0; while(!found && x< 16){ if(pos[x]!=pos2[x])found=true; x++; } if(!found){ if(global.playsound)sound.play(); nr=global.grid.next(0,0,196); global.grid.set(nr, 1); global.doboard=true; }else{ global.setInfo("Make puzzle!!"); } } public void event(){ } public void resetevent(){ System.out.println("Resetevent on object96"); } // Display public void display(){ global.boardrow=-1; global.boardcol=-1; global.doboard=true; } }