Add perlin based generation for the terrain tiles

This commit is contained in:
Marc Di Luzio 2020-07-08 20:10:28 +01:00
parent 10959ef726
commit ed9ecef80a
4 changed files with 50 additions and 6 deletions

View file

@ -1,6 +1,7 @@
package atlas
import (
"fmt"
"testing"
"github.com/mdiluz/rove/pkg/objects"
@ -248,3 +249,26 @@ func TestAtlas_GetSetCorrect(t *testing.T) {
}
}
}
func TestAtlas_WorldGen(t *testing.T) {
a := NewAtlas(8)
// Spawn a large world
_, _ = a.QueryPosition(vector.Vector{X: 20, Y: 20})
// Print out the world for manual evaluation
num := 20
for j := num - 1; j >= 0; j-- {
for i := 0; i < num; i++ {
t, o := a.QueryPosition(vector.Vector{X: i, Y: j})
if o.Type != objects.None {
fmt.Printf("%c", o.Type)
} else if t != byte(TileNone) {
fmt.Printf("%c", t)
} else {
fmt.Printf(" ")
}
}
fmt.Print("\n")
}
}