goonscape/game/world.go
2025-01-13 11:10:48 +01:00

40 lines
712 B
Go

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
}