fix supid viewport bug

This commit is contained in:
2019-11-01 19:59:12 +03:00
parent 529f5a5749
commit 17ef52a5cf
5 changed files with 29 additions and 14 deletions

View File

@ -32,7 +32,7 @@ func NewViewPort(x, y, w, h int, layer *Layer) *ViewPort {
Fov: computedFov,
}
vp.PlayerTorchRadius = 9
vp.PlayerTorchRadius = 11
vp.animateTiles = time.NewTicker(time.Second / 12)
return &vp
@ -56,11 +56,11 @@ func (vp *ViewPort) Move(state *gamestate.GameState) {
if y < 0 {
y = 0
}
if x > state.Level.W-vp.W {
if x > state.Level.W-vp.W - 1 {
x = state.Level.W - vp.W - 1
}
if y > state.Level.H-vp.H {
x = state.Level.H - vp.H - 1
if y > state.Level.H-vp.H - 1 {
y = state.Level.H - vp.H - 1
}
if x != vp.cameraCoords.X || y != vp.cameraCoords.Y {
state.FovRecompute <- struct{}{}
@ -101,12 +101,12 @@ func (vp *ViewPort) Render(state *gamestate.GameState) {
if fovRecompute {
vp.layer.ClearRect(vp.Rect)
fovRecompute = false
fovRecompute = true
redraw = true
vp.Fov.ComputeFov(state.Level, state.Player.Coords, vp.PlayerTorchRadius)
}
if redraw {
//if redraw {
//terrain
for y := 0; y < vp.H; y++ {
for x := 0; x < vp.W; x++ {
@ -114,14 +114,14 @@ func (vp *ViewPort) Render(state *gamestate.GameState) {
if state.Level.InBounds(mapCoords) {
tile := state.Level.GetTile(mapCoords)
if tile.Explored || tile.MustDraw || tile.Visible {
if tile.Explored || tile.Visible {
vp.layer.PutToBase(x+vp.X, y+vp.Y, tile.GetChar(), tile.GetRawColor(), tile.GetRawBgColor())
}
}
}
}
//mobs
pc, err := vp.ToVPCoords(vp.PlayerCoords)
pc, err := vp.ToVPCoords(state.Player.Coords)
_ = pc
if err != nil {
fmt.Println("error on getting player position")
@ -132,8 +132,8 @@ func (vp *ViewPort) Render(state *gamestate.GameState) {
}
//redraw = true
redraw = false
//redraw = false
}
//}
}