Map( Generatable GENERATOR, int TILE_SIZE, float ZOOM, int CHUNK_SIZE, Texture TILE_SHEET, RenderWindow WINDOW, int ANIMATION_FRAMES, int ANIMATION_SPEED) { this.GENERATOR = GENERATOR; this.DIMENSIONS = GENERATOR.getDimensions(); this.TILE_SIZE = TILE_SIZE; this.ZOOM = ZOOM; this.CHUNK_SIZE = CHUNK_SIZE; this.TILE_SHEET = TILE_SHEET; this.WINDOW = WINDOW; // Calculate the amount of horizontal chunks. X_CHUNKS = (int) Math.ceil((double) DIMENSIONS.x / CHUNK_SIZE); // Calculate the amount of vertical chunks. int yChunks = (int) Math.ceil((double) DIMENSIONS.y / CHUNK_SIZE); // Calculate the total amount of chunks. TOTAL_CHUNKS = X_CHUNKS * yChunks; TILE_ARRAY = GENERATOR.generate(); VERTEX_ARRAYS = new VertexArray[TOTAL_CHUNKS][ANIMATION_FRAMES]; this.ANIMATION_FRAMES = ANIMATION_FRAMES; this.ANIMATION_SPEED = ANIMATION_SPEED; animationFrame = 0; // Load the tiles into the map. partition(); }
/** * searches through all packages if there's some class that has this name. * * @param className * @return */ public String packageForGeneratable(String name) { for (PackageObject po : getPackages()) { for (Generatable g : po.getGeneratables()) { if (g.getName().equals(name)) return po.getName(); } } return null; }