com.binarytenshi.nopassing.core.MapHandler.java Source code

Java tutorial

Introduction

Here is the source code for com.binarytenshi.nopassing.core.MapHandler.java

Source

/*
 * Copyright:
 * This file was created by BinaryTENSHi and distributed
 * as part of NoPassing.
 *
 * NoPassing lies under a license which can be
 * found in the LICENSE file in the root directory
 * File created @ [26.12.2013, 19:04:40 CH timezone]
 */
package com.binarytenshi.nopassing.core;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.binarytenshi.nopassing.core.environment.StreetHandler;
import com.binarytenshi.nopassing.lib.FileHelper;
import com.binarytenshi.nopassing.lib.Path;
import com.binarytenshi.nopassing.lib.TextureLib;

public abstract class MapHandler {
    private static Vector2 mapSize;
    private static Texture grassTile;

    public static void initialize(int width, int height) {
        mapSize = new Vector2(width, height);

        StreetHandler.initialize();
        grassTile = new Texture(FileHelper.getFile(Path.Environment, "grass.png"));
    }

    public static void draw(SpriteBatch batch) {
        for (int x = 0; x < mapSize.x; x++) {
            for (int y = 0; y < mapSize.y; y++) {
                batch.draw(grassTile, x * TextureLib.tileSide, y * TextureLib.tileSide);
            }
        }

        StreetHandler.draw(batch);
    }

    public static Vector2 getMapSize() {
        return mapSize;
    }
}