Tweaks
This commit is contained in:
parent
8b0b38b488
commit
8516d1cb91
3 changed files with 305 additions and 302 deletions
|
@ -66,7 +66,6 @@ func (g *Game) Layout(outsideWidth, outsideHeight int) (w, h int) {
|
||||||
|
|
||||||
// Update updates everything.
|
// Update updates everything.
|
||||||
func (g *Game) Update() error {
|
func (g *Game) Update() error {
|
||||||
//return g.updateRecursive(g)
|
|
||||||
return g.Query(g.Root, UpdaterType,
|
return g.Query(g.Root, UpdaterType,
|
||||||
func(c interface{}) error {
|
func(c interface{}) error {
|
||||||
if d, ok := c.(Disabler); ok && d.Disabled() {
|
if d, ok := c.(Disabler); ok && d.Disabled() {
|
||||||
|
@ -109,11 +108,10 @@ func (g *Game) Children(c interface{}) ComponentSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PathRegister calls Register on every Registrar in the path between g and
|
// PathRegister calls Register on every Registrar in the path between g and
|
||||||
// parent (top-to-bottom, i.e. g first)
|
// parent (top-to-bottom, i.e. game first, component last).
|
||||||
func (g *Game) PathRegister(component, parent interface{}) error {
|
func (g *Game) PathRegister(component, parent interface{}) error {
|
||||||
rp := g.ReversePath(parent)
|
for _, p := range g.Path(parent) {
|
||||||
for i := len(rp) - 1; i >= 0; i-- {
|
if r, ok := p.(Registrar); ok {
|
||||||
if r, ok := rp[i].(Registrar); ok {
|
|
||||||
if err := r.Register(component, parent); err != nil {
|
if err := r.Register(component, parent); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -123,7 +121,7 @@ func (g *Game) PathRegister(component, parent interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PathUnregister calls Unregister on every Registrar in the path between g and
|
// PathUnregister calls Unregister on every Registrar in the path between g and
|
||||||
// parent (bottom-to-top, i.e. parent first).
|
// parent (bottom-to-top, i.e. component first, game last).
|
||||||
func (g *Game) PathUnregister(component interface{}) {
|
func (g *Game) PathUnregister(component interface{}) {
|
||||||
for _, p := range g.ReversePath(component) {
|
for _, p := range g.ReversePath(component) {
|
||||||
if r, ok := p.(Registrar); ok {
|
if r, ok := p.(Registrar); ok {
|
||||||
|
@ -147,7 +145,7 @@ func (g *Game) Path(component interface{}) []interface{} {
|
||||||
func (g *Game) ReversePath(component interface{}) []interface{} {
|
func (g *Game) ReversePath(component interface{}) []interface{} {
|
||||||
var stack []interface{}
|
var stack []interface{}
|
||||||
g.dbmu.RLock()
|
g.dbmu.RLock()
|
||||||
for p := component; p != nil; p = g.Parent(p) {
|
for p := component; p != nil; p = g.parent[p] {
|
||||||
stack = append(stack, p)
|
stack = append(stack, p)
|
||||||
}
|
}
|
||||||
g.dbmu.RUnlock()
|
g.dbmu.RUnlock()
|
||||||
|
@ -230,6 +228,9 @@ func (g *Game) Prepare(component interface{}) error {
|
||||||
// builds the component databases and then calls Prepare on every Preparer.
|
// builds the component databases and then calls Prepare on every Preparer.
|
||||||
// LoadAndPrepare must be called before any calls to Component or Query.
|
// LoadAndPrepare must be called before any calls to Component or Query.
|
||||||
func (g *Game) LoadAndPrepare(assets fs.FS) error {
|
func (g *Game) LoadAndPrepare(assets fs.FS) error {
|
||||||
|
if g.Projection == nil {
|
||||||
|
g.Projection = geom.ElevationProjection{}
|
||||||
|
}
|
||||||
if g.VoxelScale == (geom.Float3{}) {
|
if g.VoxelScale == (geom.Float3{}) {
|
||||||
g.VoxelScale = geom.Float3{X: 1, Y: 1, Z: 1}
|
g.VoxelScale = geom.Float3{X: 1, Y: 1, Z: 1}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,10 @@ func Level1() *engine.Scene {
|
||||||
Src: engine.ImageRef{Path: "assets/space.png"},
|
Src: engine.ImageRef{Path: "assets/space.png"},
|
||||||
},
|
},
|
||||||
Factor: 0.5,
|
Factor: 0.5,
|
||||||
},
|
}, // Parallax
|
||||||
|
&engine.DrawDAG{
|
||||||
|
ChunkSize: 16,
|
||||||
|
Child: engine.MakeContainer(
|
||||||
&engine.PrismMap{
|
&engine.PrismMap{
|
||||||
ID: "hexagons",
|
ID: "hexagons",
|
||||||
PosToWorld: geom.IntMatrix3x4{
|
PosToWorld: geom.IntMatrix3x4{
|
||||||
|
@ -247,8 +250,8 @@ func Level1() *engine.Scene {
|
||||||
geom.Pt3(2, 0, 12): {},
|
geom.Pt3(2, 0, 12): {},
|
||||||
|
|
||||||
geom.Pt3(0, 0, 13): {},
|
geom.Pt3(0, 0, 13): {},
|
||||||
},
|
}, // Map
|
||||||
},
|
}, // PrismMap
|
||||||
&Awakeman{
|
&Awakeman{
|
||||||
CameraID: "game_camera",
|
CameraID: "game_camera",
|
||||||
ToastID: "toast",
|
ToastID: "toast",
|
||||||
|
@ -307,9 +310,11 @@ func Level1() *engine.Scene {
|
||||||
},
|
},
|
||||||
CellSize: image.Pt(10, 16),
|
CellSize: image.Pt(10, 16),
|
||||||
Src: engine.ImageRef{Path: "assets/aw.png"},
|
Src: engine.ImageRef{Path: "assets/aw.png"},
|
||||||
},
|
}, // Sheet
|
||||||
},
|
}, // Sprite
|
||||||
},
|
}, // Awakeman
|
||||||
),
|
), // Container
|
||||||
}
|
}, // DrawDAG
|
||||||
|
), // Container
|
||||||
|
} // Scene
|
||||||
}
|
}
|
||||||
|
|
5
main.go
5
main.go
|
@ -70,13 +70,10 @@ func main() {
|
||||||
ID: "bg_fill",
|
ID: "bg_fill",
|
||||||
Color: color.Gray{100},
|
Color: color.Gray{100},
|
||||||
},
|
},
|
||||||
&engine.DrawDAG{
|
&engine.Camera{
|
||||||
ChunkSize: 16,
|
|
||||||
Child: &engine.Camera{
|
|
||||||
ID: "game_camera",
|
ID: "game_camera",
|
||||||
Child: lev1,
|
Child: lev1,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&engine.DebugToast{ID: "toast", Pos: image.Pt(0, 15)},
|
&engine.DebugToast{ID: "toast", Pos: image.Pt(0, 15)},
|
||||||
engine.PerfDisplay{},
|
engine.PerfDisplay{},
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue