2019-10-30 17:56:30 +03:00

52 lines
981 B
Go

package gamemap
import (
"lab.zaar.be/thefish/alchemyst-go/engine/ecs"
"lab.zaar.be/thefish/alchemyst-go/engine/types"
"lab.zaar.be/thefish/alchemyst-go/util"
)
//fixme move to config
var mapWidth = 150
var mapHeight = 100
type Level struct {
*types.Rect
ctx util.ClientCtx
Name string
Branch string
Depth int
Objects []ecs.Entity
Tiles [][]*Tile
}
func (l *Level) Put (x, y int, tileFunc interface{}) {
tf := tileFunc.(func() *Tile)()
if tf == nil {
l.ctx.Logger().Fatal().Msgf("Got non-tile type to put into level: %v", tf)
}
if l.InBounds(types.Coords{x, y}) {
l.Tiles[x][y] = tf
}
}
func NewLevel(ctx util.ClientCtx, branch string, depth int) *Level {
l := &Level{
Name: branch + string(depth),
Depth: depth,
Rect: types.NewRect(0,0, mapWidth, mapHeight),
}
l.Tiles = make([][]*Tile, l.W)
for i := range l.Tiles {
l.Tiles[i] = make([]*Tile, l.H)
}
return l
}
type Room struct {
*types.Rect
Center types.Coords
}