aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/Map.java
blob: db686f6870a391fab4175c4b1fecab151107e9cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.awt.Dimension;

public class Map {

    public final Dimension size;
    public final Tile grid[];

    // TODO load map from file
    // public Map(File filename) {
    public Map(Dimension size) {
        this.size = size;
        
        // populate grid
        this.grid = new Tile[this.size.width * this.size.height];
        for (int y = 0; y < this.size.width; y++) {
            for (int x = 0; x < this.size.height; x++) {
                this.grid[y * this.size.width + x] = new Tile(Tile.Type.GRASS, x, y);
            }
        }
    }

    // public void load() {}

    /* accessors */
    public Tile getTile(int x, int y) {
        return this.grid[y * this.size.width + x];
    }
}