Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Nov 21st, 2018 14 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1.  
  2.  
  3. import javafx.embed.swing.SwingFXUtils;
  4. import javafx.scene.*;
  5.  
  6. import javafx.scene.layout.Pane;
  7.  
  8. import javafx.scene.image.ImageView;
  9.  
  10. import java.awt.image.BufferedImage;
  11. import org.mapeditor.core.Map;
  12. import org.mapeditor.core.Tile;
  13. import org.mapeditor.core.TileLayer;
  14. import org.mapeditor.io.TMXMapReader;
  15.  
  16. import java.util.HashMap;
  17.  
  18. public class TileReader {
  19.    
  20.     private Pane gamePane;
  21.    
  22.  
  23.     static TMXMapReader mapReader = new TMXMapReader();
  24.     static Map map = null;
  25.     static TileLayer layer = null;
  26.     static Tile tile = null;
  27.     static int tid;
  28.  
  29.     public TileReader(Pane gamePane) {
  30.        
  31.         this.gamePane = gamePane;
  32.     }
  33.  
  34.     public void buildMap() {
  35.         Group root = new Group();
  36.         root.getChildren().add(gamePane);
  37.  
  38.         try {
  39.             map = mapReader.readMap(TileReader.class.getResource("/de/hsh/inform/darkit/gui/map1.tmx").toString());
  40.         } catch (Exception e) {
  41.             System.out.println("Datei nicht gefunden");
  42.             e.printStackTrace();
  43.         }
  44.        
  45.         /*
  46.         layer = (TileLayer) map.getLayer(1);
  47.         System.out.println("test");
  48.         if (layer == null) {
  49.             System.out.println("can't get map layer");
  50.             System.exit(-1);
  51.         }
  52.         int width = map.getWidth();
  53.         int height = map.getHeight();
  54.         HashMap<Integer, BufferedImage> tileHash = new HashMap<Integer, BufferedImage>();
  55.         BufferedImage tileImage = null;
  56.         for (int y = 0; y < height; y++) {
  57.             for (int x = 0; x < width; x++) {
  58.                 tile = layer.getTileAt(x, y);
  59.                 tid = tile.getId();
  60.                 if (tileHash.containsKey(tid)) {
  61.                     tileImage = tile.getImage();
  62.  
  63.                 } else {
  64.  
  65.                     try {
  66.  
  67.                     } catch (Exception e) {
  68.                         e.printStackTrace(); // TODO!
  69.                     }
  70.                     tileHash.put(tid, tileImage);
  71.                 }
  72.                 ImageView iv = new ImageView();
  73.                 iv.setImage(SwingFXUtils.toFXImage(tileImage, null));
  74.  
  75.                 gamePane.getChildren().add(iv);
  76.  
  77.             }
  78.         }*/
  79.  
  80.     }
  81.  
  82.  
  83. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top