import java.awt.*; import java.util.*; public class ContinuousAnimationStack{ FIFO stack=new FIFO(); int MAXOBJECTS=4000; int frames[]=new int[MAXOBJECTS]; String framestr[]=new String[MAXOBJECTS]; Global global; boolean moreactions=true; // when there are more actions , loop // because we don't want to paint empty stuff ContinuousAnimationStack(Global glb){ global=glb; for(int i=0; i-1){ global.grid.setyx(yy,xx,obj); if(obj==global.usernr){ global.playerx=xx; global.playery=yy; } }else{ doAction(action); } //System.out.println("redrawframe:yy:"+yy+","+xx+","+obj+","+dir); if(multiple){ global.game.redrawframe(yy,xx,obj,w,h,dir, framenr, oldy, oldx); }else{ global.game.redrawframe(yy,xx,obj,dir, framenr, oldy, oldx); } frames[i]=-1; framestr[i]=""; } // has more tokens } // if there is a string //global.game.redraw(yy,xx); } // while there are actions } // search all objects for same tick }catch(Exception e){ System.out.println("ContinuousAnimationStack run error: "+e.toString()); } } public void add(int tick, int y1, int x1, int object, int framenr, String action, int direction, int oldy, int oldx){ String str=y1+","+x1+","+object+","+framenr+","+action+","+direction+","+oldy+","+oldx; int ft=freetick(); if(ft != -1){ framestr[ft]=str; frames[ft]=tick; } //System.out.println("Add: tickinani"+ft+"tick in game:"+tick+":"+str); } // // animation // // w-10000 is the width of the number of grid items to draw // h-10000 is the height of the number of grid items to draw // public void add(int tick, int y1, int x1, int w, int h, int object, int framenr, String action, int direction, int oldy, int oldx){ //System.out.println("Adding multiple frames"); String str=y1+","+x1+","+w+","+h+","+object+","+framenr+","+action+","+direction+","+oldy+","+oldx; int ft=freetick(); if(ft != -1){ framestr[ft]=str; frames[ft]=tick; } //System.out.println("Add: tickinani"+ft+"tick in game:"+tick+":"+str); } public void doAction(String action){ if(action.indexOf(":")>-1){ int ij=0; String objectstring=action.substring(0,action.indexOf(":")); String objectmethod=action.substring(action.indexOf(":")+1); int o=Integer.parseInt(objectstring); String objm=objectmethod.substring(0,objectmethod.indexOf(".")); System.out.println("Perform Action on object:"+objectstring+" method:"+objectmethod+" nr: "+o+" obj: "+objm); if(objectmethod.indexOf(".")>-1){ StringTokenizer arguments=new StringTokenizer(objectmethod,"."); while(arguments.hasMoreTokens()){ String arg=arguments.nextToken(); global.gameobject[o].setArg(ij++,arg); } //while argument } //if object System.out.println("Calling :["+objm+"]"); global.gameobject[o].setMethod(objm); global.gameobject[o].execute(); } // if action else{ //nothing (false) } } }