updates
This commit is contained in:
14
engine/gamemap/level.go
Normal file
14
engine/gamemap/level.go
Normal file
@ -0,0 +1,14 @@
|
||||
package gamemap
|
||||
|
||||
import "lab.zaar.be/thefish/alchemyst-go/engine/ecs"
|
||||
|
||||
type Level struct {
|
||||
Name string
|
||||
Branch string
|
||||
Depth int
|
||||
MaxRooms int
|
||||
Width int
|
||||
Height int
|
||||
Objects []ecs.Entity
|
||||
Tiles [][]*Tile
|
||||
}
|
20
engine/gamemap/mapgen.go
Normal file
20
engine/gamemap/mapgen.go
Normal file
@ -0,0 +1,20 @@
|
||||
package gamemap
|
||||
|
||||
type mapGen interface {
|
||||
generate(l *Level) *Level
|
||||
}
|
||||
|
||||
type defaultGen struct {}
|
||||
|
||||
func (d defaultGen) generate(l *Level) *Level {
|
||||
|
||||
l.Tiles, rooms = addRooms(l)
|
||||
l. Tiles = connectRooms(rooms)
|
||||
l.Objects = populate(rooms)
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
func addRooms(l *Level) {
|
||||
|
||||
}
|
143
engine/gamemap/tile.go
Normal file
143
engine/gamemap/tile.go
Normal file
@ -0,0 +1,143 @@
|
||||
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)},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
5
engine/gamemap/types.go
Normal file
5
engine/gamemap/types.go
Normal file
@ -0,0 +1,5 @@
|
||||
package gamemap
|
||||
|
||||
type Coords struct {
|
||||
x,y int
|
||||
}
|
Reference in New Issue
Block a user