This commit is contained in:
2026-07-30 07:19:20 +02:00
parent aacbcdd5c9
commit 4a2a0d130b
2 changed files with 21 additions and 2 deletions
+8 -1
View File
@@ -52,7 +52,7 @@ Game content lives in `lib/` as package-level `var`s — one struct value
per file, no constructor functions. `main.go` only calls `lib.Run()`. per file, no constructor functions. `main.go` only calls `lib.Run()`.
``` ```
main.go func main() { lib.Run() } main.go embeds assets/ (go:embed) and calls lib.Run()
lib/ lib/
setup.go Run() and Build(); the only wiring code setup.go Run() and Build(); the only wiring code
assets.go var Assets []pncdsl.Asset assets.go var Assets []pncdsl.Asset
@@ -74,6 +74,13 @@ Adding new content means creating one file with one `var`, and adding
one `Register(...)` line in `lib/setup.go`. No registrar functions, no one `Register(...)` line in `lib/setup.go`. No registrar functions, no
indirection. indirection.
The `assets/` tree is compiled into the binary via `go:embed` and
handed to the framework through `pncdsl.AssetFS`, so the js/wasm build
(`make wasm`) ships with working art. Native builds read from the same
embedded copy — changing a PNG requires a rebuild. Files listed in
`lib/assets.go` but missing from `assets/` still fall back to the
framework's colored placeholders.
## Custom theme and chat widget ## Custom theme and chat widget
The demo ships with a game-specific theme (`morning-coffee`, warm coffee The demo ships with a game-specific theme (`morning-coffee`, warm coffee
+13 -1
View File
@@ -1,7 +1,19 @@
package main package main
import "git.teletypegames.org/games/pncdsl-demo/lib" import (
"embed"
p "git.teletypegames.org/games/pncdsl"
"git.teletypegames.org/games/pncdsl-demo/lib"
)
// The asset tree is compiled into the binary so the js/wasm build can
// load it too — in the browser there is no OS filesystem to read from.
//
//go:embed assets
var assetsFS embed.FS
func main() { func main() {
p.AssetFS = assetsFS
lib.Run() lib.Run()
} }