From 4bc7642019a49472a9f4e898f4fb06c352db2c3c Mon Sep 17 00:00:00 2001 From: kts of kettek Date: Tue, 19 Apr 2022 20:53:36 -0700 Subject: [PATCH] Actually make it decent --- data/data.go | 20 ++++++++++- data/images/deep-water.png | Bin 0 -> 92 bytes data/images/dirt.png | Bin 0 -> 92 bytes data/images/flowers.png | Bin 0 -> 161 bytes data/mapping.json | 40 +++++++++++++++++++++ gobl.go | 2 +- internal/gwfc/Game.go | 72 ++++++++++++++++++++++++++----------- internal/gwfc/Map.go | 2 +- 8 files changed, 112 insertions(+), 24 deletions(-) create mode 100644 data/images/deep-water.png create mode 100644 data/images/dirt.png create mode 100644 data/images/flowers.png create mode 100644 data/mapping.json diff --git a/data/data.go b/data/data.go index d7e5e00..ec757b3 100644 --- a/data/data.go +++ b/data/data.go @@ -2,6 +2,7 @@ package data import ( "embed" + "encoding/json" "image" "log" "path/filepath" @@ -9,10 +10,12 @@ import ( ) // FS is our exported FS. -//go:embed images/* +//go:embed images/* mapping.json var fs embed.FS var Images map[string]image.Image +var Mapping map[string][]string +var Tiles []string func Init() { Images = make(map[string]image.Image) @@ -37,4 +40,19 @@ func Init() { Images[name] = img } } + // Load mapping. + f, err := fs.Open("mapping.json") + if err != nil { + log.Fatal(err) + } + d := json.NewDecoder(f) + err = d.Decode(&Mapping) + if err != nil { + log.Fatal(err) + } + + // Add all types to the common map. + for k := range Mapping { + Mapping[""] = append(Mapping[""], k) + } } diff --git a/data/images/deep-water.png b/data/images/deep-water.png new file mode 100644 index 0000000000000000000000000000000000000000..34956490b1633e992da9b5d09792917f43ef56ad GIT binary patch literal 92 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|#5`RbLnNjq o_nfQ#F`tn?;gGszjR*t7{u@j?ZT6oj0;*u}boFyt=akR{0G5~-I{*Lx literal 0 HcmV?d00001 diff --git a/data/images/dirt.png b/data/images/dirt.png new file mode 100644 index 0000000000000000000000000000000000000000..459108135ff514a0a989d83caa15c59a3cbeca91 GIT binary patch literal 92 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|#5`RbLnNjq oznTB;>wHH3ghT3