colordance
This commit is contained in:
@ -14,10 +14,10 @@ const FPS_LIMIT = 60
|
||||
|
||||
type ViewPort struct {
|
||||
*types.Rect
|
||||
level *gamemap.Level
|
||||
layer *Layer
|
||||
Fov fov.Fov
|
||||
playerCoords types.Coords
|
||||
level *gamemap.Level
|
||||
layer *Layer
|
||||
Fov fov.Fov
|
||||
playerCoords types.Coords
|
||||
playerTorchRadius int
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ func NewViewPort(x, y, w, h int, level *gamemap.Level, layer *Layer) *ViewPort {
|
||||
Fov: fov,
|
||||
}
|
||||
|
||||
vp.playerCoords = types.Coords{10,10}
|
||||
vp.playerCoords = types.Coords{10, 10}
|
||||
vp.playerTorchRadius = 10
|
||||
|
||||
return &vp
|
||||
@ -116,17 +116,44 @@ func (vp *ViewPort) ToVPCoords(c *types.Coords) (newCoords *types.Coords, err er
|
||||
// }
|
||||
//}
|
||||
|
||||
var redraw = true
|
||||
var fovRecompute = true
|
||||
|
||||
func (vp *ViewPort) Render() {
|
||||
|
||||
if fovRecompute {
|
||||
vp.layer.Clear(vp.Rect)
|
||||
fovRecompute = false
|
||||
redraw = true
|
||||
//fixme
|
||||
|
||||
vp.Fov.ComputeFov(vp.level, vp.playerCoords, vp.playerTorchRadius)
|
||||
}
|
||||
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]
|
||||
fg := tile.ColorSet.Fg()
|
||||
bg := tile.ColorSet.Bg()
|
||||
vp.layer.WithRawColor(fg).
|
||||
PutWithRawBackground(mapCoords.X, mapCoords.Y, tile.Char, bg)
|
||||
|
||||
if tile.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
|
||||
}
|
||||
}
|
||||
|
||||
//fg := tile.ColorSet.Fg()
|
||||
//bg := tile.ColorSet.Bg()
|
||||
//vp.layer.WithRawColor(fg).
|
||||
// PutWithRawBackground(mapCoords.X, mapCoords.Y, tile.Char, bg)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user