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

@ -29,10 +29,7 @@ func TestPrecompShade(t *testing.T) {
Rect: types.NewRect(0, 0, 20, 20),
}
level.Tiles = make([][]*gamemap.Tile, level.W)
for i := range level.Tiles {
level.Tiles[i] = make([]*gamemap.Tile, level.H)
}
level.Tiles = make([]*gamemap.Tile, level.W * level.H)
var tile func() (*gamemap.Tile)
@ -43,21 +40,21 @@ func TestPrecompShade(t *testing.T) {
} else {
tile = gamemap.NewFloor
}
level.Tiles[x][y] = tile()
level.SetTileByXY(x, y, tile())
}
}
playerCoords := types.Coords{10, 10}
level.Tiles[8][12] = gamemap.NewWall()
level.Tiles[10][8] = gamemap.NewWall()
level.SetTileByXY(8, 12, gamemap.NewWall())
level.SetTileByXY(10, 8, gamemap.NewWall())
level.Tiles[7][9] = gamemap.NewWall()
level.Tiles[7][11] = gamemap.NewWall()
level.Tiles[5][10] = gamemap.NewWall()
level.SetTileByXY(7, 9, gamemap.NewWall())
level.SetTileByXY(7, 11, gamemap.NewWall())
level.SetTileByXY(5, 10, gamemap.NewWall())
level.Tiles[10][11] = gamemap.NewWall()
level.Tiles[11][10] = gamemap.NewWall()
level.SetTileByXY(10, 11, gamemap.NewWall())
level.SetTileByXY(11, 10, gamemap.NewWall())
ppFov.ComputeFov(level, playerCoords, 12)
@ -67,8 +64,8 @@ func TestPrecompShade(t *testing.T) {
if playerCoords.X == x && playerCoords.Y == y {
return "@"
}
result := level.Tiles[x][y].Char
if !level.Tiles[x][y].Visible {
result := level.GetTileByXY(x, y).Char
if !level.GetTileByXY(x, y).Visible {
result = "?"
}
return result