//************ from map class **************** public Tile[][] createTileArray(int width, int height) { if(isMade) { Tile tempTile[][] = new Tile[width][height]; System.out.println("Setting tiles to default values. " + "This may take some time depending on the size of your map..."); //Give each tile a default value for(int i = 0; i < width; i++) { for(int y = 0; y < height; y++) { tempTile[y] = new Tile(); } } System.out.println("Map tiles have had default values set succesfully!"); return tempTile; } return null; }//*********** tile class *****************************************************public class Tile { //Tile variables used by the MapHandler, GFXHandler and PlayerHandler //To determine actions //The tiles graphics String Graphic; String State2Graphic; String foregroundGFX; //Is the tile walkable? boolean isWalkable; //Is the tile an overhang causing the player to go "underneath" it? boolean isOverhang; //Does this tile have two different states? E.g. A door with opened and closed boolean hasMultipleStates; //Should the tile automatically loop through the difefrent states? boolean loopStates; //If so what should the timing be between switches? int stateSwitchTime; //What is the tiles current state? //DEFAULT 1 int currentState = 1; //X and Y co-ordinates of the tile //Used only for scrolling the tiles //These co-ordinates are relative to the real co-ordinates //E.g. X += 0.5 would move the tile Right by half a tile. int offsetX, offsetY; //NOTE: If the states are not looped the user can manually switch state in the event() method // By simply changing the value of currentState public Tile() { Graphic = "data/imgs/grass.jpg"; State2Graphic = null; foregroundGFX = null; isWalkable = true; isOverhang =false; hasMultipleStates = false; loopStates = false; stateSwitchTime = 0; currentState = 1; offsetX = 0; offsetY = 0; } //Abstract Event method. This method should be overwritten by a user defined action. //It is used by the Event handler in order to carry out specific tasks when a tile is "used" //If the tile needs no event the user need only leave the metohd empty. public void event() { }}
[java] Strange array problems
This is what you need. (Ok it works if I use pre instead of source)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement