ready to ecs

This commit is contained in:
anton.gurov 2019-10-31 18:33:37 +03:00
parent 2bb7cae632
commit fa3e3ee786
5 changed files with 43 additions and 15 deletions

View File

@ -117,12 +117,21 @@ func setupLayers(mainwindow *mainwindow.MainWindow) {
func decodeInput(ctx util.ClientCtx, baseLayer *mainwindow.Layer) {
var exit = false
//for some reason blt's input queue gots spammed with 0xE0 on start.
//with this crutch we can wait out this WindowCloseEvent burst.
var waitForStartingWindowCloseBurst = true
for !exit{
select {
case keycode := <-State.rawInput:
if keycode == blt.TK_NONE {
continue
}
if keycode == blt.TK_CLOSE && !waitForStartingWindowCloseBurst {
ctx.Logger().Warn().Msg("exiting on window close...")
State.exit <- struct{}{}
ctx.Logger().Warn().Msg("...done")
return
}
var pressed= ""
var isModifier, _= util.InArray(keycode, modifiers)
if !isModifier {
@ -154,6 +163,7 @@ func decodeInput(ctx util.ClientCtx, baseLayer *mainwindow.Layer) {
exit = true
return
default:
waitForStartingWindowCloseBurst = false
State.input <- pressed
}
}

View File

@ -6,8 +6,6 @@ import (
"math"
)
//fixme store separate FovMap, add method IsInMap to it
type FieldOfVision struct {
cosTable map[int]float64
sinTable map[int]float64

View File

@ -53,8 +53,8 @@ func NewLevel(ctx util.ClientCtx, branch string, depth int) *Level {
Depth: depth,
Rect: types.NewRect(0,0, mapWidth, mapHeight),
}
l.Tiles = make([]*Tile, l.W*l.H)
ctx.Logger().Debug().Msgf("Generating level of branch %s depth %d", branch, depth)
return l
}

View File

@ -8,7 +8,7 @@ import (
//fixme move to config
var minRoomSize = 3
var maxRoomSize = 22
var maxrooms = 30
var maxrooms = 50
//fixme make closure to stack them
func DefaultGen(l *gamemap.Level) *gamemap.Level {
@ -70,18 +70,31 @@ func DefaultGen(l *gamemap.Level) *gamemap.Level {
// Body: func() *gamemap.Tile {return gamemap.NewFloor()},
//}
//fillage := types.RectFill{
// Top: func() *gamemap.Tile {return gamemap.NewWaterTile()},
// Bottom: func() *gamemap.Tile {return gamemap.NewWaterTile()},
// Left: func() *gamemap.Tile {return gamemap.NewWaterTile()},
// Right: func() *gamemap.Tile {return gamemap.NewWaterTile()},
// BottomLeft: func() *gamemap.Tile {return gamemap.NewWaterTile()},
// BottomRight: func() *gamemap.Tile {return gamemap.NewWaterTile()},
// TopLeft: func() *gamemap.Tile {return gamemap.NewWaterTile()},
// TopRight: func() *gamemap.Tile {return gamemap.NewWaterTile()},
// Body: func() *gamemap.Tile {return gamemap.NewDeepWaterTile()},
//}
fillage := types.RectFill{
Top: func() *gamemap.Tile {return gamemap.NewWaterTile()},
Bottom: func() *gamemap.Tile {return gamemap.NewWaterTile()},
Left: func() *gamemap.Tile {return gamemap.NewWaterTile()},
Right: func() *gamemap.Tile {return gamemap.NewWaterTile()},
BottomLeft: func() *gamemap.Tile {return gamemap.NewWaterTile()},
BottomRight: func() *gamemap.Tile {return gamemap.NewWaterTile()},
TopLeft: func() *gamemap.Tile {return gamemap.NewWaterTile()},
TopRight: func() *gamemap.Tile {return gamemap.NewWaterTile()},
Body: func() *gamemap.Tile {return gamemap.NewDeepWaterTile()},
Top: func() *gamemap.Tile {return gamemap.NewFloor()},
Bottom: func() *gamemap.Tile {return gamemap.NewFloor()},
Left: func() *gamemap.Tile {return gamemap.NewFloor()},
Right: func() *gamemap.Tile {return gamemap.NewFloor()},
BottomLeft: func() *gamemap.Tile {return gamemap.NewFloor()},
BottomRight: func() *gamemap.Tile {return gamemap.NewFloor()},
TopLeft: func() *gamemap.Tile {return gamemap.NewFloor()},
TopRight: func() *gamemap.Tile {return gamemap.NewFloor()},
Body: func() *gamemap.Tile {return gamemap.NewFloor()},
}
for idx, room := range rooms {
room.Blit(fillage, l)
if idx > 0 {

View File

@ -82,6 +82,7 @@ func (t *Tile) GetChar() string {
}
func (t *Tile) GetRawColor() uint32 {
//if !t.Visible {
if !t.Visible {
return t.Appearance.ColorSet.Fg.GetColor()
} else {
@ -90,7 +91,8 @@ func (t *Tile) GetRawColor() uint32 {
}
func (t *Tile) GetRawBgColor() uint32 {
if !t.Visible {
//if !t.Visible {
if t.Visible {
return t.Appearance.ColorSet.Bg.GetColor()
} else {
return t.Appearance.ColorSet.DarkBg.GetColor()
@ -118,8 +120,13 @@ func fillColorRing(colorValue uint8, minGlow, maxGlow, step int) *cdeque {
//}
c := &cdeque{}
toss := crng.Range(0, 1) //Хаха
for _, v := range q {
c.PushBack(uint8(v))
if toss == 1 {
c.PushBack(uint8(v))
} else {
c.PushFront(uint8(v))
}
}
return c
}