Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tk.sketchistgames.level;
- import tk.sketchistgames.graphics.Screen;
- import tk.sketchistgames.level.tile.Tile;
- public class Level {
- protected int width, height;
- protected int[] tiles;
- public Level(int width, int height) {
- this.width = width;
- this.height = height;
- tiles = new int[width * height];
- generateLevel();
- }
- public Level(String path) {
- loadLevel(path);
- }
- protected void generateLevel() {
- }
- private void loadLevel(String path) {
- }
- public void update() {
- }
- private void time() { // TODO Make Real Time day/night system. Day time irl
- }
- public void render(int xScroll, int yScroll, Screen screen) {
- screen.setOffset(xScroll, yScroll);
- int x0 = xScroll >> 4;// Left
- int x1 = (xScroll + screen.getWidth()) >> 4; // Right
- int y0 = yScroll >> 4; // Top
- int y1 = (yScroll + screen.getHeight()) >> 4; // Bottom
- for (int y = y0; y < y1; y++) {
- for (int x = x0; x < x1; y++) {
- getTile(x , y).render(x, y, screen);
- }
- }
- }
- public Tile getTile(int x, int y) {
- if(tiles[x + (y * width)] == 0) return Tile.grassTile;
- return Tile.voidTile;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement