precomputed shade algo, viewport basic render

This commit is contained in:
anton.gurov
2019-10-30 17:56:30 +03:00
parent 4a77323aab
commit 3958951cd5
15 changed files with 924 additions and 26 deletions

View File

@ -26,7 +26,9 @@ func (l *Level) Put (x, y int, tileFunc interface{}) {
if tf == nil {
l.ctx.Logger().Fatal().Msgf("Got non-tile type to put into level: %v", tf)
}
l.Tiles[x][y] = tf
if l.InBounds(types.Coords{x, y}) {
l.Tiles[x][y] = tf
}
}
func NewLevel(ctx util.ClientCtx, branch string, depth int) *Level {
@ -46,5 +48,5 @@ func NewLevel(ctx util.ClientCtx, branch string, depth int) *Level {
type Room struct {
*types.Rect
Center *types.Coords
Center types.Coords
}

View File

@ -22,7 +22,7 @@ func DefaultGen(l *gamemap.Level) *gamemap.Level {
}
}
rooms := make([]*gamemap.Room, maxrooms)
rooms := make([]*gamemap.Room, 0)
for i := 0; i < maxrooms; i++ {
newRoom := &gamemap.Room{
@ -32,8 +32,7 @@ func DefaultGen(l *gamemap.Level) *gamemap.Level {
rng.Range(minRoomSize, maxRoomSize),
rng.Range(minRoomSize, maxRoomSize),
)}
newRoom.Center.X = newRoom.X + newRoom.W / 2
newRoom.Center.Y = newRoom.Y + newRoom.H / 2
newRoom.Center = types.Coords{newRoom.X + newRoom.W / 2, newRoom.Y + newRoom.H / 2}
failed := false
for _, otherRoom := range rooms {

View File

@ -39,6 +39,7 @@ type Tile struct {
BlocksPass bool
BlocksSight bool
Explored bool
Visible bool
MustDraw bool
Colordance bool
}