import java.util.*; import java.awt.*; // // Football / goal // // 48=goal // 47=ball // // Ball moves along free spaces until it hits an object // // Hole / water / fire = gone // public class object47 extends object{ public Sound football; public Sound goal; public int other=-1; int state=0; public object47(){ methods[0]="hit"; methods[1]="resetevent"; methods[2]="action1"; methods[3]="action2"; methods[4]="action3"; methods[5]="action4"; methods[6]="event"; methods[7]="event1"; methods[8]="event2"; methods[9]="event5"; objnumber=47; } public void init(Global glbl){ global=glbl; if(image==null){ image=global.loadImage(global.Server, global.Directory+"47"+global.Extention, global.show); } football=global.loadSound(global.Server, global.Directory+"47.au"); goal=global.loadSound(global.Server, global.Directory+"48.au"); } public void hit(){ global.freeze=true; if(global.playsound) football.play(); state=5; } public void execute(){ if(method.compareTo("hit")==0) hit(); if(method.compareTo("resetevent")==0) resetevent(); if(method.compareTo("event5")==0) event5(); if(method.compareTo("event") == 0) event(); } public void event5(){ int d=0; boolean score=false; other=global.grid.next(0,0,47); if(other < 0)return; global.freeze=true; //System.out.println("global.dir: "+global.dir+" other (47 place): "+other); d=global.grid.get(other+((global.WIDTH*global.STEPP)*global.STEPP)); if(global.dir == (global.STEPP*global.WIDTH)){ if(d == 1){ global.grid.set(other,1); global.grid.set(other+((global.STEPP*global.WIDTH)*global.STEPP),47); }else{ if(d == 48){ global.grid.set(other,1); global.grid.set(((global.STEPP*global.WIDTH)*global.STEPP)+other,1); score=true; state=6; } else{ state=6; } } } d=global.grid.get(other-((global.WIDTH*global.STEPP)*global.STEPP)); if(global.dir == -(global.STEPP*global.WIDTH)) { if( d == 1) { global.grid.set(other,1); global.grid.set(other-((global.STEPP*global.WIDTH)*global.STEPP),47); } else{ if(d == 48){ global.grid.set(other,1); score=true; global.grid.set(other-((global.STEPP*global.WIDTH)*global.STEPP),1); state=6; } else{ state=6; } } } d=global.grid.get(other+(global.STEPP*1)); if(global.dir == global.STEPP){ if(d == 1) { global.grid.set(other,1); global.grid.set(other+(1*global.STEPP),47); } else{ if(d == 48){ global.grid.set(other,1); global.grid.set(other+(1*global.STEPP),1); score=true; state=6; } else{ state=6; } } } d=global.grid.get(other-(global.STEPP)); if(global.dir == -(global.STEPP) ){ if( d == 1) { global.grid.set(other,1); global.grid.set(other-(1*global.STEPP),47); state=6; } else{ if(d == 48){ global.grid.set(other,1); global.grid.set(other-(1*global.STEPP),1); score=true; state=6; } else{ state=6; } } } if(score && global.playsound)goal.play(); // Change for a smaller region global.boardrow=-1; global.boardcol=-1; global.boardwidth=-1; global.boardheight=-1; global.doboard=true; } public void event(){ switch(state){ case 5: event5();break; case 6: global.freeze=false; state=7;break; } } public void resetevent(){ other=-1; state=0; } }