-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_generator_test.go
74 lines (63 loc) · 1.89 KB
/
map_generator_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package marchingsquares
import (
"image/color"
"testing"
"github.com/hajimehoshi/ebiten"
)
/**
* Guys i'm new to testing
*/
func Test_NewMapGenerator(t *testing.T) {
emptyImage, _ := ebiten.NewImage(16, 16, ebiten.FilterDefault)
emptyImage.Fill(color.White)
mg := NewMapGenerator(51, 128, 96, 10)
t.Logf("mg: %#+v\n", mg)
}
// // / not working aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
// func Test_Update(t *testing.T) {
// // var emptyImage, _ = ebiten.NewImage(16, 16, ebiten.FilterDefault)
// // emptyImage.Fill(color.White)
// // mg := NewMapGenerator(emptyImage, 51, 128, 96)
// // if err := ebiten.Run(mg.Update, 640, 480, 1, "title"); err != nil {
// if err := ebiten.Run(func (screen *ebiten.Image) error {
// return nil
// }, 640, 480, 1, "title"); err != nil {
// t.Error("run exited:", err)
// }
// }
// // /// not working
// func Test_OnDraw(t *testing.T) {
// }
func Test_RandomFillMap(t *testing.T) {
emptyImage, _ := ebiten.NewImage(16, 16, ebiten.FilterDefault)
emptyImage.Fill(color.White)
mg := NewMapGenerator(51, 8, 6, 10)
mg.atlas = RandomFillMap(mg.width, mg.height, mg.randomFillPercent)
t.Logf("atlas: %#+v\n", mg.atlas)
}
func Test_SmoothMap(t *testing.T) {
emptyImage, _ := ebiten.NewImage(16, 16, ebiten.FilterDefault)
emptyImage.Fill(color.White)
mg := NewMapGenerator(51, 8, 6, 10)
mg.atlas = RandomFillMap(mg.width, mg.height, mg.randomFillPercent)
for i := 0; i < 4; i++ {
mg.atlas = SmoothMap(mg.atlas, mg.width, mg.height)
}
t.Logf("atlas: %#+v\n", mg.atlas)
}
func Test_GenerateMap(t *testing.T) {
emptyImage, _ := ebiten.NewImage(16, 16, ebiten.FilterDefault)
emptyImage.Fill(color.White)
mg := NewMapGenerator(51, 20, 10, 10)
mg.GenerateMap()
if len(mg.atlas) < 1 {
t.Error("empty squares")
}
// call second time let guard pass
mg.GenerateMap()
for _, v := range mg.atlas {
for _, square := range v {
t.Logf("square: %#+v\n", square)
}
}
}