reorganise example

This commit is contained in:
Josh Deprez 2021-10-01 13:56:46 +10:00
parent 4a39c55f2a
commit f489680454
22 changed files with 12 additions and 20 deletions

View file

@ -1,3 +1,6 @@
//go:build example
// +build example
package main
import (
@ -11,7 +14,7 @@ import (
"runtime/pprof"
"drjosh.dev/gurgle/engine"
"drjosh.dev/gurgle/game"
"drjosh.dev/gurgle/example"
"drjosh.dev/gurgle/geom"
"github.com/hajimehoshi/ebiten/v2"
)
@ -45,9 +48,9 @@ func main() {
// Change to true to rewrite level1.gobz
lev1 := interface{}(&engine.SceneRef{Path: "assets/level1.gobz"})
if hardcodedLevel1 {
lev1 = game.Level1()
lev1 = example.Level1()
if rewriteLevel1 && runtime.GOOS != "js" {
if err := engine.SaveGobz(lev1, "game/assets/level1.gobz"); err != nil {
if err := engine.SaveGobz(lev1, "example/assets/level1.gobz"); err != nil {
log.Fatalf("Couldn't save level1.gobz: %v", err)
}
}
@ -79,12 +82,12 @@ func main() {
),
},
}
if err := g.LoadAndPrepare(game.Assets); err != nil {
if err := g.LoadAndPrepare(example.Assets); err != nil {
log.Fatalf("Loading/preparing error: %v", err)
}
if enableREPL && runtime.GOOS != "js" {
go g.REPL(os.Stdin, os.Stdout, game.Assets)
go g.REPL(os.Stdin, os.Stdout, example.Assets)
}
if err := ebiten.RunGame(g); err != nil {

View file

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View file

@ -1,7 +1,4 @@
//go:build js
// +build js
package game
package example
// TODO: make an io/fs wrapper for ebitenutil.OpenFile ?

View file

Before

Width:  |  Height:  |  Size: 201 B

After

Width:  |  Height:  |  Size: 201 B

View file

Before

Width:  |  Height:  |  Size: 868 B

After

Width:  |  Height:  |  Size: 868 B

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 472 KiB

After

Width:  |  Height:  |  Size: 472 KiB

View file

@ -1,4 +1,4 @@
package game
package example
import (
"encoding/gob"

View file

@ -1,4 +1,4 @@
package game
package example
import (
"fmt"

View file

@ -1,4 +1,4 @@
package game
package example
import (
"image"

View file

@ -1,8 +0,0 @@
//go:build !js
// +build !js
package game
import "os"
var Assets = os.DirFS("game/")