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

@ -37,7 +37,7 @@ func (f *FieldOfVision) SetTorchRadius(radius int) {
func (f *FieldOfVision) SetAllInvisible(level *gamemap.Level) {
for x := 0; x < level.W; x++ {
for y := 0; y < level.H; y++ {
level.Tiles[x][y].Visible = false
level.GetTileByXY(x,y).Visible = false
}
}
}
@ -57,7 +57,7 @@ func (f *FieldOfVision) RayCast(playerCoords types.Coords, level *gamemap.Level)
y := float64(playerCoords.Y)
// Mark the players current position as explored
tile := level.Tiles[playerCoords.X][playerCoords.Y]
tile := level.GetTile(playerCoords) //[playerCoords.X][playerCoords.Y]
tile.Explored = true
tile.Visible = true
@ -73,12 +73,12 @@ func (f *FieldOfVision) RayCast(playerCoords types.Coords, level *gamemap.Level)
break
}
tile := level.Tiles[roundedX][roundedY]
tile := level.GetTileByXY(roundedX, roundedY)
tile.Explored = true
tile.Visible = true
if level.Tiles[roundedX][roundedY].BlocksSight == true {
if level.GetTileByXY(roundedX, roundedY).BlocksSight == true {
// The ray hit a wall, go no further
break
}