123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- package me.hammerle.snuviengine.api;
- import me.hammerle.snuviengine.game.Chunk;
- import java.util.Random;
- public class Map
- {
- protected final static int PARTION = 16;
-
- private int layers;
- private int width;
- private int height;
- private short[][][] tiles;
-
- private int pWidth;
- private int pHeight;
- private Chunk[][][] chunks = null;
-
- public Map()
- {
- }
-
- public void load(String path)
- {
- /*layers = 2;
- width = 64;
- height = 64;
- tiles = new short[layers][width][height];
- Random r = new Random(100);
- for(int x = 0; x < width; x++)
- {
- for(int y = 0; y < height; y++)
- {
- tiles[0][x][y] = 0;
- }
- }
- for(int x = 0; x < width; x++)
- {
- for(int y = 0; y < height; y++)
- {
- tiles[1][x][y] = (short) (r.nextInt(2));
- }
- }
-
- if(chunks != null)
- {
- for(Chunk[][] a : chunks)
- {
- for(Chunk[] b : a)
- {
- for(Chunk c : b)
- {
- c.delete();
- }
- }
- }
- }
-
- pWidth = width / PARTION;
- pHeight = height / PARTION;
-
- chunks = new Chunk[layers][pWidth][pHeight];
- for(int l = 0; l < layers; l++)
- {
- for(int x = 0; x < pWidth; x++)
- {
- for(int y = 0; y < pHeight; y++)
- {
- chunks[l][x][y] = new Chunk();
- }
- }
- }*/
- }
-
- private float getViewX(float x)
- {
- x -= Engine.WIDTH >> 1;
- if(x < 0)
- {
- return 0;
- }
- float max = width * Engine.TILE_SIZE * Engine.SCALE - Engine.WIDTH;
- if(x > max)
- {
- return max;
- }
- return x;
- }
-
- private float getViewY(float y)
- {
- y -= Engine.HEIGHT >> 1;
- if(y < 0)
- {
- return 0;
- }
- float max = height * Engine.TILE_SIZE * Engine.SCALE - Engine.HEIGHT;
- if(y > max)
- {
- return max;
- }
- return y;
- }
- }
|