fixes to viewport, config tuning
This commit is contained in:
94
engine/types/appearance.go
Normal file
94
engine/types/appearance.go
Normal file
@ -0,0 +1,94 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/gammazero/deque"
|
||||
"lab.zaar.be/thefish/alchemyst-go/util"
|
||||
)
|
||||
import blt "lab.zaar.be/thefish/bearlibterminal"
|
||||
|
||||
var crng = util.NewRNG()
|
||||
|
||||
type ColorHolder interface {
|
||||
GetColor() uint32
|
||||
}
|
||||
|
||||
type cdeque struct {
|
||||
deque.Deque
|
||||
}
|
||||
|
||||
func (c *cdeque) Next() uint8 {
|
||||
c.Rotate(1)
|
||||
return c.Front().(uint8)
|
||||
}
|
||||
|
||||
type DanceColorHolder struct {
|
||||
A uint8
|
||||
R *cdeque
|
||||
G *cdeque
|
||||
B *cdeque
|
||||
}
|
||||
|
||||
func (chd *DanceColorHolder) GetColor() uint32 {
|
||||
return blt.ColorFromARGB(
|
||||
chd.A,
|
||||
chd.R.Next(),
|
||||
chd.G.Next(),
|
||||
chd.B.Next(),
|
||||
)
|
||||
}
|
||||
|
||||
type PlainColorHolder struct {
|
||||
A uint8
|
||||
R uint8
|
||||
G uint8
|
||||
B uint8
|
||||
}
|
||||
|
||||
func (chb *PlainColorHolder) GetColor() uint32 {
|
||||
return blt.ColorFromARGB(
|
||||
chb.A,
|
||||
chb.R,
|
||||
chb.G,
|
||||
chb.B,
|
||||
)
|
||||
}
|
||||
|
||||
type TileColorSet struct {
|
||||
Fg ColorHolder
|
||||
Bg ColorHolder
|
||||
DarkFg ColorHolder
|
||||
DarkBg ColorHolder
|
||||
}
|
||||
|
||||
type Appearance struct {
|
||||
Char string `json:"char"`
|
||||
ColorSet *TileColorSet `json:"colorSet"`
|
||||
}
|
||||
|
||||
|
||||
func SingleColorRing(colorValue uint8) *cdeque {
|
||||
c := &cdeque{}
|
||||
c.PushBack(colorValue)
|
||||
return c
|
||||
}
|
||||
|
||||
func FillColorRing(colorValue uint8, minGlow, maxGlow, step int) *cdeque {
|
||||
q := make([]uint8, 0)
|
||||
color := int(colorValue)
|
||||
for color < maxGlow {
|
||||
q = append(q, uint8(color))
|
||||
color = crng.Range(1, step) + color
|
||||
}
|
||||
color = crng.Range(0, step+minGlow)
|
||||
q = append(q, uint8(color))
|
||||
//for uint8(color) < uint8(colorValue) {
|
||||
// q = append(q, uint8(color))
|
||||
// color = crng.Range(1, step+minGlow)
|
||||
//}
|
||||
|
||||
c := &cdeque{}
|
||||
for _, v := range q {
|
||||
c.PushBack(uint8(v))
|
||||
}
|
||||
return c
|
||||
}
|
20
engine/types/gamestate.go
Normal file
20
engine/types/gamestate.go
Normal file
@ -0,0 +1,20 @@
|
||||
package types
|
||||
|
||||
type GameState struct {
|
||||
Mainfunc chan func()
|
||||
Exit chan struct{}
|
||||
Input chan string
|
||||
RawInput chan int
|
||||
FovRecompute chan struct{}
|
||||
Redraw chan struct{}
|
||||
}
|
||||
|
||||
// do runs f on the main thread.
|
||||
func (g *GameState) Do(f func()) {
|
||||
done := make(chan struct{}, 1)
|
||||
g.Mainfunc <- func() {
|
||||
f()
|
||||
done <- struct{}{}
|
||||
}
|
||||
<-done
|
||||
}
|
Reference in New Issue
Block a user