with backgroung + composition
This commit is contained in:
@ -45,11 +45,14 @@ func (layer *Layer) PutWithRawBackground(x,y int, symbol interface{}, bgColor ui
|
||||
func (layer *Layer) PutWithBackground(x,y int, symbol interface{}, bgColorName string) {
|
||||
layer.before()
|
||||
prevColor := uint32(blt.State(blt.TK_COLOR))
|
||||
prevCompMode := blt.State(blt.TK_COMPOSITION)
|
||||
c := blt.ColorFromName(bgColorName)
|
||||
blt.Color(c)
|
||||
blt.Composition(1)
|
||||
layer.Put(x,y,"█")
|
||||
blt.Color(prevColor)
|
||||
layer.Put(x,y, symbol)
|
||||
blt.Composition(prevCompMode)
|
||||
}
|
||||
|
||||
func (layer *Layer) after() *Layer {
|
||||
|
@ -53,49 +53,49 @@ func (vp *ViewPort) ToVPCoords(c *types.Coords) (newCoords *types.Coords, err er
|
||||
}
|
||||
|
||||
//call only from main thread
|
||||
func (vp *ViewPort) Render() {
|
||||
//fixme get these from state chan(s)
|
||||
var fpsTicker int
|
||||
var fovRecompute bool
|
||||
redraw := false
|
||||
//fixme get player instance
|
||||
|
||||
vp.Move(player.Coords)
|
||||
//fixme detect fovRecompute
|
||||
if fovRecompute {
|
||||
vp.layer.Clear(vp.Rect)
|
||||
fovRecompute = false
|
||||
redraw = true
|
||||
//fixme
|
||||
vp.level.ComputeFov(FovMap, player.Coords, player.TorchRadius, FovLightWalls, FovAlgo)
|
||||
}
|
||||
//increase ticker
|
||||
fpsTicker++
|
||||
|
||||
if redraw || fpsTicker % (FPS_LIMIT / 10) == 0 {
|
||||
fpsTicker := 0
|
||||
|
||||
for y:=0; y < vp.H; y++ {
|
||||
for x:=0; x<vp.W; x++ {
|
||||
mapCoords := types.Coords{vp.X + x, vp.Y + y}
|
||||
tile := vp.level.Tiles[mapCoords.X][mapCoords.Y]
|
||||
visible := vp.IsInFov(mapCoords)
|
||||
if !visible {
|
||||
if tile.MustDraw {
|
||||
//darkened version of landscape
|
||||
vp.layer.WithRawColor(tile.ColorSet.DarkFg()).
|
||||
PutWithRawBackground(mapCoords.X, mapCoords.Y, tile.Char, tile.ColorSet.DarkBg())
|
||||
}
|
||||
} else {
|
||||
if redraw == true || tile.Colordance {
|
||||
vp.layer.WithRawColor(tile.ColorSet.Fg()).
|
||||
PutWithRawBackground(mapCoords.X, mapCoords.Y, tile.Char, tile.ColorSet.Bg())
|
||||
tile.Explored = true
|
||||
tile.MustDraw = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//func (vp *ViewPort) Render() {
|
||||
// //fixme get these from state chan(s)
|
||||
// var fpsTicker int
|
||||
// var fovRecompute bool
|
||||
// redraw := false
|
||||
// //fixme get player instance
|
||||
//
|
||||
// vp.Move(player.Coords)
|
||||
// //fixme detect fovRecompute
|
||||
// if fovRecompute {
|
||||
// vp.layer.Clear(vp.Rect)
|
||||
// fovRecompute = false
|
||||
// redraw = true
|
||||
// //fixme
|
||||
// vp.level.ComputeFov(FovMap, player.Coords, player.TorchRadius, FovLightWalls, FovAlgo)
|
||||
// }
|
||||
// //increase ticker
|
||||
// fpsTicker++
|
||||
//
|
||||
// if redraw || fpsTicker % (FPS_LIMIT / 10) == 0 {
|
||||
// fpsTicker := 0
|
||||
//
|
||||
// for y:=0; y < vp.H; y++ {
|
||||
// for x:=0; x<vp.W; x++ {
|
||||
// mapCoords := types.Coords{vp.X + x, vp.Y + y}
|
||||
// tile := vp.level.Tiles[mapCoords.X][mapCoords.Y]
|
||||
// visible := vp.IsInFov(mapCoords)
|
||||
// if !visible {
|
||||
// if tile.MustDraw {
|
||||
// //darkened version of landscape
|
||||
// vp.layer.WithRawColor(tile.ColorSet.DarkFg()).
|
||||
// PutWithRawBackground(mapCoords.X, mapCoords.Y, tile.Char, tile.ColorSet.DarkBg())
|
||||
// }
|
||||
// } else {
|
||||
// if redraw == true || tile.Colordance {
|
||||
// vp.layer.WithRawColor(tile.ColorSet.Fg()).
|
||||
// PutWithRawBackground(mapCoords.X, mapCoords.Y, tile.Char, tile.ColorSet.Bg())
|
||||
// tile.Explored = true
|
||||
// tile.MustDraw = true
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
Reference in New Issue
Block a user