This commit is contained in:
Josh Deprez 2021-09-30 09:36:06 +10:00
parent 8b0b38b488
commit 8516d1cb91
3 changed files with 305 additions and 302 deletions

View file

@ -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}
} }

View file

@ -21,295 +21,300 @@ 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.PrismMap{ &engine.DrawDAG{
ID: "hexagons", ChunkSize: 16,
PosToWorld: geom.IntMatrix3x4{ Child: engine.MakeContainer(
// For each tile in the X direction, go right by 24 and &engine.PrismMap{
// forward by 8, etc ID: "hexagons",
0: [4]int{24, 0, 0, 0}, PosToWorld: geom.IntMatrix3x4{
1: [4]int{0, 16, 0, 0}, // For each tile in the X direction, go right by 24 and
2: [4]int{8, 0, 16, 0}, // forward by 8, etc
}, 0: [4]int{24, 0, 0, 0},
PrismSize: geom.Int3{X: 32, Y: 16, Z: 16}, 1: [4]int{0, 16, 0, 0},
PrismTop: []image.Point{ 2: [4]int{8, 0, 16, 0},
{X: 8, Y: 0},
{X: 0, Y: 8},
{X: 8, Y: 16},
{X: 23, Y: 16},
{X: 31, Y: 8},
{X: 23, Y: 0},
},
Sheet: engine.Sheet{
CellSize: image.Pt(32, 32),
Src: engine.ImageRef{Path: "assets/hexprism32.png"},
},
Map: map[geom.Int3]*engine.Prism{
geom.Pt3(11, 0, -6): {},
geom.Pt3(12, 0, -6): {},
geom.Pt3(9, 0, -5): {},
geom.Pt3(10, 0, -5): {},
geom.Pt3(11, 0, -5): {},
geom.Pt3(12, 0, -5): {},
geom.Pt3(7, 0, -4): {},
geom.Pt3(8, 0, -4): {},
geom.Pt3(9, 0, -4): {},
geom.Pt3(10, 0, -4): {},
geom.Pt3(11, 0, -4): {},
geom.Pt3(12, 0, -4): {},
geom.Pt3(5, 0, -3): {},
geom.Pt3(6, 0, -3): {},
geom.Pt3(7, 0, -3): {},
geom.Pt3(8, 0, -3): {},
geom.Pt3(9, 0, -3): {},
geom.Pt3(10, 0, -3): {},
geom.Pt3(11, 0, -3): {},
geom.Pt3(12, 0, -3): {},
geom.Pt3(3, 0, -2): {},
geom.Pt3(4, 0, -2): {},
geom.Pt3(5, 0, -2): {},
geom.Pt3(6, 0, -2): {},
geom.Pt3(7, 0, -2): {},
geom.Pt3(8, 0, -2): {},
geom.Pt3(9, 0, -2): {},
geom.Pt3(10, 0, -2): {},
geom.Pt3(11, 0, -2): {},
geom.Pt3(12, 0, -2): {},
geom.Pt3(1, 0, -1): {},
geom.Pt3(2, 0, -1): {},
geom.Pt3(3, 0, -1): {},
geom.Pt3(4, 0, -1): {},
geom.Pt3(5, 0, -1): {},
geom.Pt3(6, 0, -1): {},
geom.Pt3(7, 0, -1): {},
geom.Pt3(8, 0, -1): {},
geom.Pt3(9, 0, -1): {},
geom.Pt3(10, 0, -1): {},
geom.Pt3(11, 0, -1): {},
geom.Pt3(12, 0, -1): {},
geom.Pt3(0, 0, 0): {},
geom.Pt3(1, 0, 0): {},
geom.Pt3(2, 0, 0): {},
geom.Pt3(3, 0, 0): {},
geom.Pt3(4, 0, 0): {},
geom.Pt3(5, 0, 0): {},
geom.Pt3(6, 0, 0): {},
geom.Pt3(7, 0, 0): {},
geom.Pt3(8, 0, 0): {},
geom.Pt3(9, 0, 0): {},
geom.Pt3(10, 0, 0): {},
geom.Pt3(11, 0, 0): {},
geom.Pt3(12, 0, 0): {},
geom.Pt3(0, 0, 1): {},
geom.Pt3(1, 0, 1): {},
geom.Pt3(2, 0, 1): {},
geom.Pt3(3, 0, 1): {},
geom.Pt3(4, 0, 1): {},
geom.Pt3(5, 0, 1): {},
geom.Pt3(6, 0, 1): {},
geom.Pt3(7, 0, 1): {},
geom.Pt3(8, 0, 1): {},
geom.Pt3(9, 0, 1): {},
geom.Pt3(10, 0, 1): {},
geom.Pt3(11, 0, 1): {},
geom.Pt3(12, 0, 1): {},
geom.Pt3(0, 0, 2): {},
geom.Pt3(1, 0, 2): {},
geom.Pt3(2, 0, 2): {},
geom.Pt3(3, 0, 2): {},
geom.Pt3(4, 0, 2): {},
geom.Pt3(5, 0, 2): {},
geom.Pt3(6, 0, 2): {},
geom.Pt3(7, 0, 2): {},
geom.Pt3(8, 0, 2): {},
geom.Pt3(9, 0, 2): {},
geom.Pt3(10, 0, 2): {},
geom.Pt3(11, 0, 2): {},
geom.Pt3(12, 0, 2): {},
geom.Pt3(0, 0, 3): {},
geom.Pt3(1, 0, 3): {},
geom.Pt3(2, 0, 3): {},
geom.Pt3(3, 0, 3): {},
geom.Pt3(4, 0, 3): {},
geom.Pt3(5, 0, 3): {},
geom.Pt3(6, 0, 3): {},
geom.Pt3(7, 0, 3): {},
geom.Pt3(8, 0, 3): {},
geom.Pt3(9, 0, 3): {},
geom.Pt3(10, 0, 3): {},
geom.Pt3(11, 0, 3): {},
geom.Pt3(12, 0, 3): {},
geom.Pt3(0, 0, 4): {},
geom.Pt3(1, 0, 4): {},
geom.Pt3(2, 0, 4): {},
geom.Pt3(3, 0, 4): {},
geom.Pt3(4, 0, 4): {},
geom.Pt3(5, 0, 4): {},
geom.Pt3(6, 0, 4): {},
geom.Pt3(7, 0, 4): {},
geom.Pt3(8, 0, 4): {},
geom.Pt3(9, 0, 4): {},
geom.Pt3(10, 0, 4): {},
geom.Pt3(11, 0, 4): {},
geom.Pt3(12, 0, 4): {},
geom.Pt3(0, 0, 5): {},
geom.Pt3(1, 0, 5): {},
geom.Pt3(2, 0, 5): {},
geom.Pt3(3, 0, 5): {},
geom.Pt3(4, 0, 5): {},
geom.Pt3(5, 0, 5): {},
geom.Pt3(6, 0, 5): {},
geom.Pt3(6, -1, 5): {Cell: 1},
geom.Pt3(7, 0, 5): {},
geom.Pt3(8, 0, 5): {},
geom.Pt3(9, 0, 5): {},
geom.Pt3(10, 0, 5): {},
geom.Pt3(11, 0, 5): {},
geom.Pt3(12, 0, 5): {},
geom.Pt3(0, 0, 6): {},
geom.Pt3(1, 0, 6): {},
geom.Pt3(2, 0, 6): {},
geom.Pt3(3, 0, 6): {},
geom.Pt3(4, 0, 6): {},
geom.Pt3(5, 0, 6): {},
geom.Pt3(6, 0, 6): {},
geom.Pt3(7, 0, 6): {},
geom.Pt3(8, 0, 6): {},
geom.Pt3(9, 0, 6): {},
geom.Pt3(10, 0, 6): {},
geom.Pt3(11, 0, 6): {},
geom.Pt3(12, 0, 6): {},
geom.Pt3(0, 0, 7): {},
geom.Pt3(1, 0, 7): {},
geom.Pt3(2, 0, 7): {},
geom.Pt3(3, 0, 7): {},
geom.Pt3(4, 0, 7): {},
geom.Pt3(5, 0, 7): {},
geom.Pt3(6, 0, 7): {},
geom.Pt3(7, 0, 7): {},
geom.Pt3(8, 0, 7): {},
geom.Pt3(9, 0, 7): {},
geom.Pt3(10, 0, 7): {},
geom.Pt3(11, 0, 7): {},
geom.Pt3(12, 0, 7): {},
geom.Pt3(0, 0, 8): {},
geom.Pt3(1, 0, 8): {},
geom.Pt3(2, 0, 8): {},
geom.Pt3(3, 0, 8): {},
geom.Pt3(4, 0, 8): {},
geom.Pt3(5, 0, 8): {},
geom.Pt3(6, 0, 8): {},
geom.Pt3(7, 0, 8): {},
geom.Pt3(8, 0, 8): {},
geom.Pt3(9, 0, 8): {},
geom.Pt3(10, 0, 8): {},
geom.Pt3(0, 0, 9): {},
geom.Pt3(1, 0, 9): {},
geom.Pt3(2, 0, 9): {},
geom.Pt3(3, 0, 9): {},
geom.Pt3(4, 0, 9): {},
geom.Pt3(5, 0, 9): {},
geom.Pt3(6, 0, 9): {},
geom.Pt3(7, 0, 9): {},
geom.Pt3(8, 0, 9): {},
geom.Pt3(0, 0, 10): {},
geom.Pt3(1, 0, 10): {},
geom.Pt3(2, 0, 10): {},
geom.Pt3(3, 0, 10): {},
geom.Pt3(4, 0, 10): {},
geom.Pt3(5, 0, 10): {},
geom.Pt3(6, 0, 10): {},
geom.Pt3(0, 0, 11): {},
geom.Pt3(1, 0, 11): {},
geom.Pt3(2, 0, 11): {},
geom.Pt3(3, 0, 11): {},
geom.Pt3(4, 0, 11): {},
geom.Pt3(0, 0, 12): {},
geom.Pt3(1, 0, 12): {},
geom.Pt3(2, 0, 12): {},
geom.Pt3(0, 0, 13): {},
},
},
&Awakeman{
CameraID: "game_camera",
ToastID: "toast",
Sprite: engine.Sprite{
Actor: engine.Actor{
CollisionDomain: "level_1",
Pos: geom.Pt3(100, -64, 100),
Bounds: geom.Box{
Min: geom.Pt3(-4, -15, -1),
Max: geom.Pt3(4, 1, 1),
}, },
}, PrismSize: geom.Int3{X: 32, Y: 16, Z: 16},
DrawOffset: image.Pt(-5, -15), PrismTop: []image.Point{
Sheet: engine.Sheet{ {X: 8, Y: 0},
AnimDefs: map[string]*engine.AnimDef{ {X: 0, Y: 8},
"idle_left": {Steps: []engine.AnimStep{ {X: 8, Y: 16},
{Cell: 1, Duration: 60}, {X: 23, Y: 16},
}}, {X: 31, Y: 8},
"idle_right": {Steps: []engine.AnimStep{ {X: 23, Y: 0},
{Cell: 0, Duration: 60},
}},
"run_left": {Steps: []engine.AnimStep{
{Cell: 14, Duration: 3},
{Cell: 15, Duration: 5},
{Cell: 16, Duration: 3},
{Cell: 17, Duration: 3},
}},
"run_right": {Steps: []engine.AnimStep{
{Cell: 10, Duration: 3},
{Cell: 11, Duration: 5},
{Cell: 12, Duration: 3},
{Cell: 13, Duration: 3},
}},
"run_vert": {Steps: []engine.AnimStep{
{Cell: 18, Duration: 3},
{Cell: 19, Duration: 5},
{Cell: 20, Duration: 3},
{Cell: 21, Duration: 3},
{Cell: 22, Duration: 3},
{Cell: 23, Duration: 5},
{Cell: 24, Duration: 3},
{Cell: 25, Duration: 3},
}},
"walk_left": {Steps: []engine.AnimStep{
{Cell: 2, Duration: 6},
{Cell: 3, Duration: 6},
{Cell: 4, Duration: 6},
{Cell: 5, Duration: 6},
}},
"walk_right": {Steps: []engine.AnimStep{
{Cell: 6, Duration: 6},
{Cell: 7, Duration: 6},
{Cell: 8, Duration: 6},
{Cell: 9, Duration: 6},
}},
}, },
CellSize: image.Pt(10, 16), Sheet: engine.Sheet{
Src: engine.ImageRef{Path: "assets/aw.png"}, CellSize: image.Pt(32, 32),
}, Src: engine.ImageRef{Path: "assets/hexprism32.png"},
}, },
}, Map: map[geom.Int3]*engine.Prism{
), geom.Pt3(11, 0, -6): {},
} geom.Pt3(12, 0, -6): {},
geom.Pt3(9, 0, -5): {},
geom.Pt3(10, 0, -5): {},
geom.Pt3(11, 0, -5): {},
geom.Pt3(12, 0, -5): {},
geom.Pt3(7, 0, -4): {},
geom.Pt3(8, 0, -4): {},
geom.Pt3(9, 0, -4): {},
geom.Pt3(10, 0, -4): {},
geom.Pt3(11, 0, -4): {},
geom.Pt3(12, 0, -4): {},
geom.Pt3(5, 0, -3): {},
geom.Pt3(6, 0, -3): {},
geom.Pt3(7, 0, -3): {},
geom.Pt3(8, 0, -3): {},
geom.Pt3(9, 0, -3): {},
geom.Pt3(10, 0, -3): {},
geom.Pt3(11, 0, -3): {},
geom.Pt3(12, 0, -3): {},
geom.Pt3(3, 0, -2): {},
geom.Pt3(4, 0, -2): {},
geom.Pt3(5, 0, -2): {},
geom.Pt3(6, 0, -2): {},
geom.Pt3(7, 0, -2): {},
geom.Pt3(8, 0, -2): {},
geom.Pt3(9, 0, -2): {},
geom.Pt3(10, 0, -2): {},
geom.Pt3(11, 0, -2): {},
geom.Pt3(12, 0, -2): {},
geom.Pt3(1, 0, -1): {},
geom.Pt3(2, 0, -1): {},
geom.Pt3(3, 0, -1): {},
geom.Pt3(4, 0, -1): {},
geom.Pt3(5, 0, -1): {},
geom.Pt3(6, 0, -1): {},
geom.Pt3(7, 0, -1): {},
geom.Pt3(8, 0, -1): {},
geom.Pt3(9, 0, -1): {},
geom.Pt3(10, 0, -1): {},
geom.Pt3(11, 0, -1): {},
geom.Pt3(12, 0, -1): {},
geom.Pt3(0, 0, 0): {},
geom.Pt3(1, 0, 0): {},
geom.Pt3(2, 0, 0): {},
geom.Pt3(3, 0, 0): {},
geom.Pt3(4, 0, 0): {},
geom.Pt3(5, 0, 0): {},
geom.Pt3(6, 0, 0): {},
geom.Pt3(7, 0, 0): {},
geom.Pt3(8, 0, 0): {},
geom.Pt3(9, 0, 0): {},
geom.Pt3(10, 0, 0): {},
geom.Pt3(11, 0, 0): {},
geom.Pt3(12, 0, 0): {},
geom.Pt3(0, 0, 1): {},
geom.Pt3(1, 0, 1): {},
geom.Pt3(2, 0, 1): {},
geom.Pt3(3, 0, 1): {},
geom.Pt3(4, 0, 1): {},
geom.Pt3(5, 0, 1): {},
geom.Pt3(6, 0, 1): {},
geom.Pt3(7, 0, 1): {},
geom.Pt3(8, 0, 1): {},
geom.Pt3(9, 0, 1): {},
geom.Pt3(10, 0, 1): {},
geom.Pt3(11, 0, 1): {},
geom.Pt3(12, 0, 1): {},
geom.Pt3(0, 0, 2): {},
geom.Pt3(1, 0, 2): {},
geom.Pt3(2, 0, 2): {},
geom.Pt3(3, 0, 2): {},
geom.Pt3(4, 0, 2): {},
geom.Pt3(5, 0, 2): {},
geom.Pt3(6, 0, 2): {},
geom.Pt3(7, 0, 2): {},
geom.Pt3(8, 0, 2): {},
geom.Pt3(9, 0, 2): {},
geom.Pt3(10, 0, 2): {},
geom.Pt3(11, 0, 2): {},
geom.Pt3(12, 0, 2): {},
geom.Pt3(0, 0, 3): {},
geom.Pt3(1, 0, 3): {},
geom.Pt3(2, 0, 3): {},
geom.Pt3(3, 0, 3): {},
geom.Pt3(4, 0, 3): {},
geom.Pt3(5, 0, 3): {},
geom.Pt3(6, 0, 3): {},
geom.Pt3(7, 0, 3): {},
geom.Pt3(8, 0, 3): {},
geom.Pt3(9, 0, 3): {},
geom.Pt3(10, 0, 3): {},
geom.Pt3(11, 0, 3): {},
geom.Pt3(12, 0, 3): {},
geom.Pt3(0, 0, 4): {},
geom.Pt3(1, 0, 4): {},
geom.Pt3(2, 0, 4): {},
geom.Pt3(3, 0, 4): {},
geom.Pt3(4, 0, 4): {},
geom.Pt3(5, 0, 4): {},
geom.Pt3(6, 0, 4): {},
geom.Pt3(7, 0, 4): {},
geom.Pt3(8, 0, 4): {},
geom.Pt3(9, 0, 4): {},
geom.Pt3(10, 0, 4): {},
geom.Pt3(11, 0, 4): {},
geom.Pt3(12, 0, 4): {},
geom.Pt3(0, 0, 5): {},
geom.Pt3(1, 0, 5): {},
geom.Pt3(2, 0, 5): {},
geom.Pt3(3, 0, 5): {},
geom.Pt3(4, 0, 5): {},
geom.Pt3(5, 0, 5): {},
geom.Pt3(6, 0, 5): {},
geom.Pt3(6, -1, 5): {Cell: 1},
geom.Pt3(7, 0, 5): {},
geom.Pt3(8, 0, 5): {},
geom.Pt3(9, 0, 5): {},
geom.Pt3(10, 0, 5): {},
geom.Pt3(11, 0, 5): {},
geom.Pt3(12, 0, 5): {},
geom.Pt3(0, 0, 6): {},
geom.Pt3(1, 0, 6): {},
geom.Pt3(2, 0, 6): {},
geom.Pt3(3, 0, 6): {},
geom.Pt3(4, 0, 6): {},
geom.Pt3(5, 0, 6): {},
geom.Pt3(6, 0, 6): {},
geom.Pt3(7, 0, 6): {},
geom.Pt3(8, 0, 6): {},
geom.Pt3(9, 0, 6): {},
geom.Pt3(10, 0, 6): {},
geom.Pt3(11, 0, 6): {},
geom.Pt3(12, 0, 6): {},
geom.Pt3(0, 0, 7): {},
geom.Pt3(1, 0, 7): {},
geom.Pt3(2, 0, 7): {},
geom.Pt3(3, 0, 7): {},
geom.Pt3(4, 0, 7): {},
geom.Pt3(5, 0, 7): {},
geom.Pt3(6, 0, 7): {},
geom.Pt3(7, 0, 7): {},
geom.Pt3(8, 0, 7): {},
geom.Pt3(9, 0, 7): {},
geom.Pt3(10, 0, 7): {},
geom.Pt3(11, 0, 7): {},
geom.Pt3(12, 0, 7): {},
geom.Pt3(0, 0, 8): {},
geom.Pt3(1, 0, 8): {},
geom.Pt3(2, 0, 8): {},
geom.Pt3(3, 0, 8): {},
geom.Pt3(4, 0, 8): {},
geom.Pt3(5, 0, 8): {},
geom.Pt3(6, 0, 8): {},
geom.Pt3(7, 0, 8): {},
geom.Pt3(8, 0, 8): {},
geom.Pt3(9, 0, 8): {},
geom.Pt3(10, 0, 8): {},
geom.Pt3(0, 0, 9): {},
geom.Pt3(1, 0, 9): {},
geom.Pt3(2, 0, 9): {},
geom.Pt3(3, 0, 9): {},
geom.Pt3(4, 0, 9): {},
geom.Pt3(5, 0, 9): {},
geom.Pt3(6, 0, 9): {},
geom.Pt3(7, 0, 9): {},
geom.Pt3(8, 0, 9): {},
geom.Pt3(0, 0, 10): {},
geom.Pt3(1, 0, 10): {},
geom.Pt3(2, 0, 10): {},
geom.Pt3(3, 0, 10): {},
geom.Pt3(4, 0, 10): {},
geom.Pt3(5, 0, 10): {},
geom.Pt3(6, 0, 10): {},
geom.Pt3(0, 0, 11): {},
geom.Pt3(1, 0, 11): {},
geom.Pt3(2, 0, 11): {},
geom.Pt3(3, 0, 11): {},
geom.Pt3(4, 0, 11): {},
geom.Pt3(0, 0, 12): {},
geom.Pt3(1, 0, 12): {},
geom.Pt3(2, 0, 12): {},
geom.Pt3(0, 0, 13): {},
}, // Map
}, // PrismMap
&Awakeman{
CameraID: "game_camera",
ToastID: "toast",
Sprite: engine.Sprite{
Actor: engine.Actor{
CollisionDomain: "level_1",
Pos: geom.Pt3(100, -64, 100),
Bounds: geom.Box{
Min: geom.Pt3(-4, -15, -1),
Max: geom.Pt3(4, 1, 1),
},
},
DrawOffset: image.Pt(-5, -15),
Sheet: engine.Sheet{
AnimDefs: map[string]*engine.AnimDef{
"idle_left": {Steps: []engine.AnimStep{
{Cell: 1, Duration: 60},
}},
"idle_right": {Steps: []engine.AnimStep{
{Cell: 0, Duration: 60},
}},
"run_left": {Steps: []engine.AnimStep{
{Cell: 14, Duration: 3},
{Cell: 15, Duration: 5},
{Cell: 16, Duration: 3},
{Cell: 17, Duration: 3},
}},
"run_right": {Steps: []engine.AnimStep{
{Cell: 10, Duration: 3},
{Cell: 11, Duration: 5},
{Cell: 12, Duration: 3},
{Cell: 13, Duration: 3},
}},
"run_vert": {Steps: []engine.AnimStep{
{Cell: 18, Duration: 3},
{Cell: 19, Duration: 5},
{Cell: 20, Duration: 3},
{Cell: 21, Duration: 3},
{Cell: 22, Duration: 3},
{Cell: 23, Duration: 5},
{Cell: 24, Duration: 3},
{Cell: 25, Duration: 3},
}},
"walk_left": {Steps: []engine.AnimStep{
{Cell: 2, Duration: 6},
{Cell: 3, Duration: 6},
{Cell: 4, Duration: 6},
{Cell: 5, Duration: 6},
}},
"walk_right": {Steps: []engine.AnimStep{
{Cell: 6, Duration: 6},
{Cell: 7, Duration: 6},
{Cell: 8, Duration: 6},
{Cell: 9, Duration: 6},
}},
},
CellSize: image.Pt(10, 16),
Src: engine.ImageRef{Path: "assets/aw.png"},
}, // Sheet
}, // Sprite
}, // Awakeman
), // Container
}, // DrawDAG
), // Container
} // Scene
} }

View file

@ -70,12 +70,9 @@ func main() {
ID: "bg_fill", ID: "bg_fill",
Color: color.Gray{100}, Color: color.Gray{100},
}, },
&engine.DrawDAG{ &engine.Camera{
ChunkSize: 16, ID: "game_camera",
Child: &engine.Camera{ Child: lev1,
ID: "game_camera",
Child: lev1,
},
}, },
&engine.DebugToast{ID: "toast", Pos: image.Pt(0, 15)}, &engine.DebugToast{ID: "toast", Pos: image.Pt(0, 15)},
engine.PerfDisplay{}, engine.PerfDisplay{},