hardcoded vs rewrite
This commit is contained in:
parent
96572165e6
commit
5bf3b88881
1 changed files with 13 additions and 11 deletions
24
main.go
24
main.go
|
@ -16,7 +16,8 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
enableCPUProfile = false
|
enableCPUProfile = false
|
||||||
rewriteLevel1 = true
|
hardcodedLevel1 = true
|
||||||
|
rewriteLevel1 = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -38,8 +39,14 @@ func main() {
|
||||||
ebiten.SetWindowTitle("TODO")
|
ebiten.SetWindowTitle("TODO")
|
||||||
|
|
||||||
// Change to true to rewrite level1.gobz
|
// Change to true to rewrite level1.gobz
|
||||||
if rewriteLevel1 && runtime.GOOS != "js" {
|
lev1 := interface{}(&engine.SceneRef{Path: "assets/level1.gobz"})
|
||||||
writeLevel1()
|
if hardcodedLevel1 {
|
||||||
|
lev1 = level1()
|
||||||
|
if rewriteLevel1 && runtime.GOOS != "js" {
|
||||||
|
if err := engine.SaveGobz(lev1, "game/assets/level1.gobz"); err != nil {
|
||||||
|
log.Fatalf("Couldn't save level1.gobz: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g := &engine.Game{
|
g := &engine.Game{
|
||||||
|
@ -49,7 +56,7 @@ func main() {
|
||||||
Components: []interface{}{
|
Components: []interface{}{
|
||||||
&engine.Camera{
|
&engine.Camera{
|
||||||
ID: "game_camera",
|
ID: "game_camera",
|
||||||
Child: &engine.SceneRef{Path: "assets/level1.gobz"},
|
Child: lev1,
|
||||||
},
|
},
|
||||||
&engine.DebugToast{ID: "toast", Pos: image.Pt(0, 15)},
|
&engine.DebugToast{ID: "toast", Pos: image.Pt(0, 15)},
|
||||||
engine.PerfDisplay{},
|
engine.PerfDisplay{},
|
||||||
|
@ -71,8 +78,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// writeLevel1 dumps a test level into level1.gobz
|
func level1() *engine.Scene {
|
||||||
func writeLevel1() {
|
|
||||||
denseTiles := [][]engine.Tile{
|
denseTiles := [][]engine.Tile{
|
||||||
{engine.StaticTile(9), nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, engine.StaticTile(9)},
|
{engine.StaticTile(9), nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, engine.StaticTile(9)},
|
||||||
{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &engine.AnimatedTile{AnimKey: "red_tile"}, nil, nil, nil, nil, nil, nil, nil, nil, nil},
|
{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &engine.AnimatedTile{AnimKey: "red_tile"}, nil, nil, nil, nil, nil, nil, nil, nil, nil},
|
||||||
|
@ -100,7 +106,7 @@ func writeLevel1() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
level1 := &engine.Scene{
|
return &engine.Scene{
|
||||||
ID: "level_1",
|
ID: "level_1",
|
||||||
Bounds: engine.Bounds(image.Rect(-32, -32, 320+32, 240+32)),
|
Bounds: engine.Bounds(image.Rect(-32, -32, 320+32, 240+32)),
|
||||||
Components: []interface{}{
|
Components: []interface{}{
|
||||||
|
@ -234,8 +240,4 @@ func writeLevel1() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := engine.SaveGobz(level1, "game/assets/level1.gobz"); err != nil {
|
|
||||||
log.Fatalf("Couldn't save level1.gobz: %v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue