-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_wasm.go
More file actions
39 lines (31 loc) · 892 Bytes
/
Copy pathmain_wasm.go
File metadata and controls
39 lines (31 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//go:build js && wasm
package main
import (
"errors"
"log"
demo1 "goengine/games/demo1"
"goengine/frameengine/application/config"
"goengine/frameengine/application/engine"
"goengine/frameengine/application/game"
"goengine/frameengine/ports"
"goengine/frameengine/view/scene"
)
// sceneFactories are the scene types this WASM build (demo1 only) needs. See main.go's comment
// for why registration happens here rather than in the engine itself.
var sceneFactories = map[string]scene.SceneFactory{
"world_scene": func() (ports.Scene, error) { return scene.NewWorldScene(), nil },
}
func main() {
cfg, err := config.LoadFromFS(demo1.FS, "config.yaml")
if err != nil {
log.Fatal("config: ", err)
}
e := engine.New(cfg, sceneFactories)
defer e.Shutdown()
if err := e.Run(); err != nil {
if errors.Is(err, game.ErrShutdownRequested) {
return
}
log.Fatal(err)
}
}