package game

import (
	"gitea.boner.be/bdnugget/goonscape/types"
)

var (
	mapGrid [][]types.Tile
)

func GetMapGrid() [][]types.Tile {
	return mapGrid
}

func InitWorld() {
	mapGrid = make([][]types.Tile, types.MapWidth)
	for x := 0; x < types.MapWidth; x++ {
		mapGrid[x] = make([]types.Tile, types.MapHeight)
		for y := 0; y < types.MapHeight; y++ {
			mapGrid[x][y] = types.Tile{
				X:        x,
				Y:        y,
				Height:   1.0 + float32(x%5),
				Walkable: true,
			}
		}
	}
}

func GetTile(x, y int) types.Tile {
	if x >= 0 && x < types.MapWidth && y >= 0 && y < types.MapHeight {
		return mapGrid[x][y]
	}
	return types.Tile{}
}

func GetTileHeight(x, y int) float32 {
	return mapGrid[x][y].Height
}
