2021-07-23 13:12:54 +10:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-07-25 14:15:39 +10:00
|
|
|
_ "image/png"
|
2021-07-23 13:12:54 +10:00
|
|
|
"log"
|
2021-08-25 16:46:30 +10:00
|
|
|
"os"
|
2021-08-25 16:54:22 +10:00
|
|
|
"runtime"
|
2021-07-23 13:12:54 +10:00
|
|
|
|
|
|
|
"drjosh.dev/gurgle/engine"
|
2021-08-05 12:26:41 +10:00
|
|
|
"drjosh.dev/gurgle/game"
|
2021-07-23 13:12:54 +10:00
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-08-05 14:36:07 +10:00
|
|
|
ebiten.SetWindowResizable(true)
|
|
|
|
ebiten.SetWindowSize(640, 480)
|
2021-07-25 14:15:39 +10:00
|
|
|
ebiten.SetWindowTitle("TODO")
|
|
|
|
|
2021-08-25 14:25:45 +10:00
|
|
|
g := &engine.Game{
|
2021-08-05 14:36:07 +10:00
|
|
|
ScreenHeight: 240,
|
|
|
|
ScreenWidth: 320,
|
2021-08-20 16:46:26 +10:00
|
|
|
Root: &engine.Scene{
|
2021-08-02 12:16:10 +10:00
|
|
|
ID: "root",
|
2021-07-30 16:11:01 +10:00
|
|
|
Components: []interface{}{
|
2021-08-08 22:07:55 +10:00
|
|
|
&engine.Camera{
|
2021-08-20 13:45:01 +10:00
|
|
|
ID: "game_camera",
|
2021-08-25 15:04:38 +10:00
|
|
|
Scene: &engine.SceneRef{Path: "assets/level1.gobz"},
|
2021-08-08 22:07:55 +10:00
|
|
|
},
|
2021-08-25 16:14:40 +10:00
|
|
|
&engine.DebugToast{ID: "toast"},
|
2021-07-30 16:11:01 +10:00
|
|
|
engine.PerfDisplay{},
|
|
|
|
},
|
2021-07-23 13:12:54 +10:00
|
|
|
},
|
2021-07-25 15:03:10 +10:00
|
|
|
}
|
2021-08-25 14:25:45 +10:00
|
|
|
if err := g.Load(game.Assets); err != nil {
|
2021-08-20 16:23:10 +10:00
|
|
|
log.Fatalf("Loading error: %v", err)
|
|
|
|
}
|
2021-08-25 14:25:45 +10:00
|
|
|
g.Prepare()
|
2021-07-25 15:03:10 +10:00
|
|
|
|
2021-08-26 10:03:11 +10:00
|
|
|
if runtime.GOOS != "js" {
|
|
|
|
// Run a repl on the console.
|
|
|
|
go g.REPL(os.Stdin, os.Stdout, game.Assets)
|
|
|
|
}
|
2021-08-25 16:46:30 +10:00
|
|
|
|
|
|
|
// ... while the game also runs
|
2021-08-25 14:25:45 +10:00
|
|
|
if err := ebiten.RunGame(g); err != nil {
|
2021-07-23 14:59:49 +10:00
|
|
|
log.Fatalf("Game error: %v", err)
|
2021-07-23 13:12:54 +10:00
|
|
|
}
|
|
|
|
}
|