import java.util.*; import java.awt.*; // // WOOD // // public class object33 implements GameObject{ int teller=0; public Image image; public Sound sound; public Global global; public String arg1=new String(""); public String arg2=new String(""); public String method=new String(""); public String retval=new String(""); public String list[]=new String[10]; int state=0; int objnumber=33; int pos=0; boolean debug=false; String methods[]={ "add", "delete", "hit", "event1", "event2", "event", "resetevent", ""}; public void init(Global glbl){ global=glbl; if(debug)System.out.println("init object33!"); image=global.loadImage(global.Server, global.Directory+getNr()+global.Extention, global.game); sound=global.loadSound(global.Server, global.Directory+"1.au"); for(int i=0; i<10;i++) list[i]=new String(""); } public Image getImage(int framenr,int dir){return image;} public void execute(){ if(method.compareTo("add")==0) add(); if(method.compareTo("hit")==0) hit(); if(method.compareTo("event")==0) event(); if(method.compareTo("event1")==0) event1(); if(method.compareTo("event2")==0) event2(); if(method.compareTo("resetevent")==0) resetevent(); } public void setMethod(String s){ method=s; } public String getRetval(){ return retval; } public void setArg(int i, String value){ list[i]=value; } public void add(){ System.out.println("arg1: "+list[0]+" "+list[1]); retval=arg1+arg2; } public boolean is(String meth){ boolean retval=false; int m=methods.length; for(int i=0; i < m && !retval; i++){ if(methods[i].compareTo(meth) == 0) retval=true; } return retval; } public void hit(){ if(global.playsound) if(sound!=null){ //System.out.println("Sound 1=null oplay!"); sound.play(); } int mf=global.MAXFRAMES; int nextobj=0; int animationframe=0; int objectframes=global.PLAYERFRAMES; String action=""; // move object switch(global.dir){ case 0: // right nextobj=global.grid.getobject(global.playery, global.playerx+(mf*2)); switch(nextobj){ case 1: global.right_push(getNr(), global.PLAYERFRAMES); break; case 3: // water case 4: // hole global.grid.setyx(global.playery,global.playerx,global.oldobject); global.grid.setyx(global.playery,global.playerx+global.MAXFRAMES,global.oldobject); for(int i=0; i objectframes-1)animationframe=0; // end of animation .. what do we do next? action="true"; global.animationstack.add(global.frameticker,global.playery, global.playerx+i+mf, getNr() ,animationframe,action, global.dir, global.playery, global.playerx+mf); global.animationstack.add(global.frameticker++,global.playery, global.playerx+i, global.usernr,animationframe,i==global.MAXFRAMES?"true":"false", global.dir, global.playery, global.playerx); } // for if(nextobj==4){ // hole // the argument object is 0 so that the object will not be drawn. // the issue is that we want to execute the object4.rockinhole // but only when the animation frame is ready for it .... global.animationstack.add(global.frameticker++,global.playery, global.playerx+(mf*3), 0 ,animationframe,"4:woodinhole."+(global.playerx+(mf*2))+"."+global.playery, global.dir, global.playery, global.playerx); } if(nextobj==3){ // water global.animationstack.add(global.frameticker++,global.playery, global.playerx+(mf*3), 0 ,animationframe,"3:woodinwater."+(global.playerx+(mf*2))+"."+global.playery, global.dir, global.playery, global.playerx); } break; } break; case 1: // up nextobj=global.grid.getobject(global.playery-(mf*2), global.playerx); switch(nextobj){ case 1: global.up_push(getNr(), global.PLAYERFRAMES); break; case 3: // water case 4: // hole global.grid.setyx(global.playery,global.playerx,global.oldobject); global.grid.setyx(global.playery-global.MAXFRAMES,global.playerx,global.oldobject); for(int i=0; i objectframes-1)animationframe=0; // end of animation .. what do we do next? action="true"; global.animationstack.add(global.frameticker,global.playery-i-mf, global.playerx, getNr() ,animationframe,action, global.dir, global.playery-mf, global.playerx); global.animationstack.add(global.frameticker++,global.playery-i, global.playerx, global.usernr,animationframe,i==global.MAXFRAMES?"true":"false", global.dir, global.playery, global.playerx); } // for if(nextobj==4){ // hole // the argument object is 0 so that the object will not be drawn. // the issue is that we want to execute the object4.rockinhole // but only when the animation frame is ready for it .... global.animationstack.add(global.frameticker++,global.playery-(mf*3), global.playerx, 0 ,animationframe,"4:woodinhole."+global.playerx+"."+(global.playery-(mf*2)), global.dir, global.playery, global.playerx); } if(nextobj==3){ // water global.animationstack.add(global.frameticker++,global.playery-(mf*3), global.playerx, 0 ,animationframe,"3:woodinwater."+global.playerx+"."+(global.playery-(mf*2)), global.dir, global.playery, global.playerx); } break; } break; case 2: // left nextobj=global.grid.getobject(global.playery, global.playerx-(mf*2)); switch(nextobj){ default: global.left_push(getNr(), global.PLAYERFRAMES); break; case 3: // water case 4: // hole global.grid.setyx(global.playery,global.playerx,global.oldobject); global.grid.setyx(global.playery,global.playerx-global.MAXFRAMES,1); for(int i=0; i objectframes-1)animationframe=0; // end of animation .. what do we do next? action="true"; global.animationstack.add(global.frameticker,global.playery, global.playerx-i-mf, getNr() ,animationframe,action, global.dir, global.playery, global.playerx-mf); global.animationstack.add(global.frameticker++,global.playery, global.playerx-i, global.usernr,animationframe,i==global.MAXFRAMES?"true":"false", global.dir, global.playery, global.playerx); } // for if(nextobj==4){ // hole // the argument object is 0 so that the object will not be drawn. // the issue is that we want to execute the object4.rockinhole // but only when the animation frame is ready for it .... global.animationstack.add(global.frameticker++,global.playery, global.playerx-(mf*3), 0 ,animationframe,"4:woodinhole."+(global.playerx-(mf*2))+"."+global.playery, global.dir, global.playery, global.playerx); } if(nextobj==3){ // water global.animationstack.add(global.frameticker++,global.playery, global.playerx-(mf*3), 0 ,animationframe,"3:woodinwater."+(global.playerx-(mf*2))+"."+global.playery, global.dir, global.playery, global.playerx); } break; } break; case 3: // down nextobj=global.grid.getobject(global.playery+(mf*2), global.playerx); switch(nextobj){ case 1: global.down_push(getNr(), global.PLAYERFRAMES); break; case 3: // water case 4: // hole global.grid.setyx(global.playery,global.playerx,global.oldobject); global.grid.setyx(global.playery+global.MAXFRAMES,global.playerx,global.oldobject); for(int i=0; i objectframes-1)animationframe=0; // end of animation .. what do we do next? action="true"; global.animationstack.add(global.frameticker,global.playery+i+mf, global.playerx, getNr() ,animationframe,action, global.dir, global.playery+mf, global.playerx); global.animationstack.add(global.frameticker++,global.playery+i, global.playerx, global.usernr,animationframe,i==global.MAXFRAMES?"true":"false", global.dir, global.playery, global.playerx); } // for if(nextobj==4){ // hole // the argument object is 0 so that the object will not be drawn. // the issue is that we want to execute the object4.rockinhole // but only when the animation frame is ready for it .... global.animationstack.add(global.frameticker++,global.playery+(mf*3), global.playerx, 0 ,animationframe,"4:woodinhole."+global.playerx+"."+(global.playery+(mf*2)), global.dir, global.playery, global.playerx); } if(nextobj==3){ // water global.animationstack.add(global.frameticker++,global.playery+(mf*3), global.playerx, 0 ,animationframe,"3:woodinwater."+global.playerx+"."+(global.playery+(mf*2)), global.dir, global.playery, global.playerx); } break; } break; } } public void event2(){ } public void event1(){ } public String toString(){ return "object33"; } public int getNr(){return objnumber;} public void resetevent(){ } public void event(){ // put everything here like a 'run' method switch(state){ case 1: event1(); break; case 2: event2(); break; } // draw image } }