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

@ -1,6 +1,9 @@
package gamemap
import "lab.zaar.be/thefish/alchemyst-go/util"
import (
"container/ring"
"lab.zaar.be/thefish/alchemyst-go/util"
)
import blt "lab.zaar.be/thefish/bearlibterminal"
type ColorHolder struct {
@ -24,6 +27,28 @@ type Appearance struct {
var crng = util.NewRNG()
func NewColorComponentRing(colorValue uint8, minGlow, maxGlow, step int) *ring.Ring {
q := make([]uint8, 0)
color := int(colorValue)
for color < maxGlow {
q = append(q, uint8(color))
color = crng.Range(0, step) + color
}
color = crng.Range(0, step + minGlow)
for uint8(color) < colorValue {
q = append(q, uint8(color))
color = crng.Range(0, step + minGlow)
}
r := ring.New(len(q))
for _, v := range q {
r.Next().Value = v
}
return r
}
func colordance(colorValue uint8, minGlow, maxGlow, step int) uint8 {
color := crng.Range(0, step) + int(colorValue)
if color > maxGlow {