Skip to content

Commit

Permalink
fix: reduce max possible height of terrain hills
Browse files Browse the repository at this point in the history
From time to time there was tank on the highest hill shown out of
screen.

Now maximum possible height of hills is reduced to keep some space for
tank with its label.
  • Loading branch information
zladovan committed May 27, 2020
1 parent b5fd81a commit f672fc4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion terrain.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func GenerateTerrain(g *TerrainGenerator) *Terrain {
noise := osx.NewNormalized(g.Seed)
heights := make([]int, g.Width)
for x := 0; x < g.Width; x++ {
heights[x] = int(float64(g.Height) * noise.Eval2(g.Roughness/float64(g.Width)*float64(x), 0.5))
// reduce height to keep 5 cells space for tank on the highest hill top
heights[x] = 5 + int(float64(g.Height-5)*noise.Eval2(g.Roughness/float64(g.Width)*float64(x), 0.5))
}
return &Terrain{line: heights, height: g.Height}
}
Expand Down

0 comments on commit f672fc4

Please sign in to comment.