Advertisement
Guest User

Tilemap

a guest
Apr 24th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. package intothedwarfness.Classes;
  2.  
  3. import java.awt.image.BufferedImage;
  4. import java.io.File;
  5. import java.io.IOException;
  6. import java.util.ArrayList;
  7.  
  8. import javax.imageio.ImageIO;
  9.  
  10.  
  11. public class Tilemap
  12. {
  13.     private BufferedImage image;
  14.     private int srcX1, srcY1, srcX2, srcY2;
  15.     private static ArrayList<Tilemap> TilemapList = new ArrayList<>();
  16.    
  17.     public Tilemap(int srcX1, int srcY1, int srcX2, int srcY2)
  18.     {
  19.         this.srcX1 = srcX1;
  20.         this.srcY1 = srcY1;
  21.         this.srcX2 = srcX2;
  22.         this.srcY2 = srcY2;
  23.  
  24.         TilemapList.add(this);     
  25.        
  26.         createTile();
  27.     }
  28.  
  29.     public static ArrayList<Tilemap> Tile()
  30.     {      
  31.         /*
  32.         try
  33.         {
  34.             image = ImageIO.read(new File("src/Images/Dungeon_Tileset.png"));
  35.         }
  36.         catch(IOException e)
  37.         {
  38.             e.printStackTrace();
  39.         }*/
  40.        
  41.         return TilemapList;
  42.     }
  43.    
  44.     public void createTile()
  45.     {
  46.         int x, y;
  47.        
  48.         this.srcX1 = 0;
  49.         this.srcY1 = 0;
  50.         this.srcX2 = 32;
  51.         this.srcY2 = 32;               
  52.        
  53.         for(y = 0; y < 20; y++)
  54.         {          
  55.             for(x = 0; x < 16; x++)
  56.             {              
  57.                 this.srcX1 = 32 * x;
  58.                 this.srcX2 = this.srcX1 + 32;              
  59.                
  60.                 TilemapList.add(this);
  61.                
  62.                 System.out.println(TilemapList.size());
  63.             }  
  64.  
  65.             this.srcX1 = 0;
  66.             this.srcX2 = 0;            
  67.             this.srcY1 = 32 * y;
  68.             this.srcY2 = this.srcY1 + 32;          
  69.         }
  70.     }
  71.    
  72.     public int getSrcX1()
  73.     {
  74.         return srcX1;
  75.     }
  76.  
  77.     public void setSrcX1(int srcX1) {
  78.         this.srcX1 = srcX1;
  79.     }
  80.  
  81.     public int getSrcY1()
  82.     {
  83.         return srcY1;
  84.     }
  85.  
  86.     public void setSrcY1(int srcY1)
  87.     {
  88.         this.srcY1 = srcY1;
  89.     }
  90.  
  91.     public int getSrcX2()
  92.     {
  93.         return srcX2;
  94.     }
  95.  
  96.     public void setSrcX2(int srcX2)
  97.     {
  98.         this.srcX2 = srcX2;
  99.     }
  100.  
  101.     public int getSrcY2()
  102.     {
  103.         return srcY2;
  104.     }
  105.  
  106.     public void setSrcY2(int srcY2)
  107.     {
  108.         this.srcY2 = srcY2;
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement