Advertisement
rooster5105

MapBuilder.java

Oct 29th, 2011
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. package com.kfgeeks.java.Mapper;
  2.  
  3. public class MapBuilder {
  4.    
  5.     public static void run(int x, int y){
  6.         Map worldMap = new Map();
  7.         worldMap = buildMap(x, y);
  8.         worldMap = IslandBuilder.run(worldMap);
  9.         printMap(worldMap);
  10.     }
  11.    
  12.     private static Map buildMap(int x, int y) {
  13.         Map worldMap = new Map();
  14.         worldMap.setHeight(x);
  15.         worldMap.setWidth(y);
  16.         worldMap.mapCells = new Cell[worldMap.getHeight()][];
  17.         for (int i = 0; i < worldMap.mapCells.length; i++) {
  18.             worldMap.mapCells[i] = new Cell[worldMap.getWidth()];
  19.             for (int j = 0; j < worldMap.mapCells[i].length; j++) {
  20.                 worldMap.mapCells[i][j] = new Cell();
  21.                 worldMap.mapCells[i][j].setTerrain(0);
  22.             }
  23.         }
  24.         return worldMap;
  25.     }
  26.  
  27.    
  28.    
  29.    
  30.  
  31.     // Just a clever little Print function();
  32.     @SuppressWarnings("unused")
  33.     private void print(String s) {
  34.         System.out.println(s);
  35.     }
  36.  
  37.     private static void printMap(Map passWorld_Map) {
  38.         Map worldMap = passWorld_Map;
  39.         for (int i = 0; i < worldMap.mapCells.length; i++) {
  40.             for (int j = 0; j < worldMap.mapCells[i].length; j++) {
  41.                 System.out.print(worldMap.mapCells[i][j].getTerrain_Char());
  42.             }
  43.             System.out.print("\n");
  44.         }
  45.     }
  46. }
  47.  
  48.  
  49.  
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement