144 lines
3.1 KiB
Go
144 lines
3.1 KiB
Go
package gamemap
|
|
|
|
import "lab.zaar.be/thefish/alchemyst-go/util"
|
|
import blt "lab.zaar.be/thefish/bearlibterminal"
|
|
|
|
type ColorHolder struct {
|
|
R uint8
|
|
G uint8
|
|
B uint8
|
|
}
|
|
|
|
type TileColorSet struct {
|
|
Fg func() uint32
|
|
Bg func() uint32
|
|
DarkFg func() uint32
|
|
DarkBg func() uint32
|
|
current *ColorHolder
|
|
}
|
|
|
|
type Appearance struct {
|
|
Char string
|
|
ColorSet *TileColorSet
|
|
}
|
|
|
|
var crng = util.NewRNG()
|
|
|
|
func colordance(colorValue uint8, minGlow, maxGlow, step int) uint8 {
|
|
color := crng.Range(0, step) + int(colorValue)
|
|
if color > maxGlow {
|
|
color = crng.Range(0, step) + minGlow
|
|
}
|
|
return uint8(color)
|
|
}
|
|
|
|
type Tile struct {
|
|
*Appearance
|
|
Name string
|
|
Description string
|
|
BlocksPass bool
|
|
BlocksSight bool
|
|
Explored bool
|
|
MustDraw bool
|
|
}
|
|
|
|
|
|
func NewWall() *Tile {
|
|
return &Tile{
|
|
Name: "Wall",
|
|
Description: "A dull rock wall",
|
|
BlocksPass: true,
|
|
BlocksSight: true,
|
|
Explored: false,
|
|
MustDraw: false,
|
|
Appearance: &Appearance{
|
|
Char: "#",
|
|
ColorSet: &TileColorSet{
|
|
Fg: func() uint32 {return blt.ColorFromARGB(255, 130,110,150)},
|
|
Bg: func() uint32 {return blt.ColorFromARGB(255, 172,170,173)},
|
|
DarkFg: func() uint32 {return blt.ColorFromARGB(255, 20,20,68)},
|
|
DarkBg: func() uint32 {return blt.ColorFromARGB(255, 7,7,30)},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func NewFloor() *Tile {
|
|
return &Tile{
|
|
Name: "Floor",
|
|
Description: "Dusty rock floor",
|
|
BlocksPass: false,
|
|
BlocksSight: false,
|
|
Explored: false,
|
|
MustDraw: false,
|
|
Appearance: &Appearance{
|
|
Char: ".",
|
|
ColorSet: &TileColorSet{
|
|
Fg: func() uint32 {return blt.ColorFromARGB(255, 220,220,250)},
|
|
Bg: func() uint32 {return blt.ColorFromARGB(255, 19,19,70)},
|
|
DarkFg: func() uint32 {return blt.ColorFromARGB(255, 30,20,50)},
|
|
DarkBg: func() uint32 {return blt.ColorFromARGB(255, 7,7,30)},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func NewWaterTile() *Tile {
|
|
ch := &ColorHolder{19,19,70}
|
|
return &Tile {
|
|
Name: "Water",
|
|
Description: "Murky water",
|
|
BlocksPass: false,
|
|
BlocksSight: false,
|
|
Explored: false,
|
|
MustDraw: true, //fixme debug
|
|
Appearance: &Appearance{
|
|
Char: ".",
|
|
ColorSet: &TileColorSet{
|
|
current: ch,
|
|
Fg: func() uint32 {return blt.ColorFromARGB(255, 220,220,250)},
|
|
Bg: func() uint32 {
|
|
return blt.ColorFromARGB(
|
|
255,
|
|
ch.R,
|
|
colordance(ch.G, 2, 42, 4 ),
|
|
colordance(ch.B, 180,229,12),
|
|
)
|
|
},
|
|
DarkFg: func() uint32 {return blt.ColorFromARGB(255, 30,20,50)},
|
|
DarkBg: func() uint32 {return blt.ColorFromARGB(255, 7,7,30)},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func NewDeepWaterTile() *Tile {
|
|
ch := &ColorHolder{5,2,154}
|
|
return &Tile {
|
|
Name: "Deep Water",
|
|
Description: "Deep water",
|
|
BlocksPass: false,
|
|
BlocksSight: false,
|
|
Explored: false,
|
|
MustDraw: true, //fixme debug
|
|
Appearance: &Appearance{
|
|
Char: " ",
|
|
ColorSet: &TileColorSet{
|
|
current: ch,
|
|
Fg: func() uint32 {return blt.ColorFromARGB(255, 220,220,250)},
|
|
Bg: func() uint32 {
|
|
return blt.ColorFromARGB(
|
|
255,
|
|
ch.R,
|
|
colordance(ch.G, 0, 15, 2 ),
|
|
colordance(ch.B, 120,180,5),
|
|
)
|
|
},
|
|
DarkFg: func() uint32 {return blt.ColorFromARGB(255, 30,20,50)},
|
|
DarkBg: func() uint32 {return blt.ColorFromARGB(255, 7,7,30)},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|