refactor level, getting to tiles

This commit is contained in:
anton.gurov
2019-10-31 14:01:54 +03:00
parent e0bab00a23
commit c372670953
11 changed files with 189 additions and 180 deletions

View File

@ -129,30 +129,47 @@ func (vp *ViewPort) Render() {
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]
//
// 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
// }
// }
// }
//}
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]
tile := vp.level.GetTile(mapCoords)
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())
vp.layer.WithColor("green").
Put(mapCoords.X, mapCoords.Y, tile.Char)
}
} else {
if redraw == true || tile.Colordance {
vp.layer.WithRawColor(tile.ColorSet.Fg()).
PutWithRawBackground(mapCoords.X, mapCoords.Y, tile.Char, tile.ColorSet.Bg())
vp.layer.WithColor("white").
Put(mapCoords.X, mapCoords.Y, tile.Char)
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)
}
}