commit d74acc58def0f4cc0193b4aea9c3a4e1f7640efa Author: Zsolt Tasnadi Date: Mon May 25 21:28:04 2026 +0200 initial commit diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..5afdf5f --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright © 2026 Teletype Games + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..bf776bd --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +# pncdsl-demo — Morning Coffee + +A short point-and-click adventure built on the +[`pncdsl`](https://git.teletypegames.org/games/pncdsl) framework. Two scenes, +three items, one NPC dialog and an ending cutscene — small on purpose, +designed as an end-to-end reference for someone learning the library. + +Full walkthrough and file layout: [`DEMO.md`](DEMO.md). + +## Running it + +The library is fetched as a regular Go module. Prerequisites: Go 1.24+ +and SSH access to `git.teletypegames.org` (the private host that serves the +`pncdsl` repo). + +```bash +git clone ssh://git@git.teletypegames.org:2222/games/pncdsl-demo +cd pncdsl-demo +go mod tidy # fetches git.teletypegames.org/games/pncdsl +go run . +``` + +A 1280×800 window opens. + +### Pointing Go at the private host + +If `go mod tidy` can't reach `git.teletypegames.org` over HTTPS, ask Go to +clone via SSH instead. One-time setup: + +```bash +git config --global \ + url."ssh://git@git.teletypegames.org:2222/".insteadOf "https://git.teletypegames.org/" +export GOPRIVATE=git.teletypegames.org/* +``` + +(Add `GOPRIVATE=git.teletypegames.org/*` to your shell profile to make it +permanent.) + +### Local-development override + +While iterating on the framework and the demo in parallel, point Go at a +local checkout of `pncdsl` with a temporary `replace` directive: + +```bash +go mod edit -replace=git.teletypegames.org/games/pncdsl=../pncdsl +go mod tidy +``` + +Remove the `replace` line before pushing. + +## Controls + +| Action | Effect | +|--------|--------| +| left click on a hotspot/UI button | run the active verb | +| left click on an inventory item | select it (cursor picks it up) | +| left click on a hotspot with item selected | use-with | +| right click | deselect held item, or reset verb to Look | +| click during dialog | advance line / pick choice | +| **F1** | toggle hotspot debug overlay | + +## License + +MIT — see [`LICENSE.md`](LICENSE.md). Copyright © 2026 Teletype Games. diff --git a/assets/bg/bedroom.png b/assets/bg/bedroom.png new file mode 100644 index 0000000..5f30155 Binary files /dev/null and b/assets/bg/bedroom.png differ diff --git a/assets/bg/kitchen.png b/assets/bg/kitchen.png new file mode 100644 index 0000000..bd3d5b3 Binary files /dev/null and b/assets/bg/kitchen.png differ diff --git a/assets/spr/player.png b/assets/spr/player.png new file mode 100644 index 0000000..2d85d45 Binary files /dev/null and b/assets/spr/player.png differ diff --git a/domain/build_test.go b/domain/build_test.go new file mode 100644 index 0000000..c96cbb4 --- /dev/null +++ b/domain/build_test.go @@ -0,0 +1,29 @@ +package domain + +import "testing" + +// TestBuildValidates is the headless smoke test described in PLAN.md: +// it composes the full game and asks the library to cross-check every +// name reference between managers. No window opens. +func TestBuildValidates(t *testing.T) { + g := Build() + if err := g.Validate(); err != nil { + t.Fatalf("validate: %v", err) + } + for _, name := range []string{"bedroom", "kitchen"} { + if !g.SceneManager.Has(name) { + t.Errorf("missing scene %q", name) + } + } + for _, name := range []string{"key", "beans", "mug"} { + if !g.ItemManager.Has(name) { + t.Errorf("missing item %q", name) + } + } + if !g.DialogueManager.Has("cat_morning") { + t.Errorf("missing dialogue cat_morning") + } + if !g.ScriptManager.Has("intro") || !g.ScriptManager.Has("victory") { + t.Errorf("missing intro/victory script") + } +} diff --git a/domain/character.cat.go b/domain/character.cat.go new file mode 100644 index 0000000..1a23857 --- /dev/null +++ b/domain/character.cat.go @@ -0,0 +1,18 @@ +package domain + +import ( + "image/color" + + p "git.teletypegames.org/games/pncdsl" +) + +func defineCat(g *p.Game) { + g.CharacterManager.Register(p.Character{ + Name: "cat", + Sprite: "spr/cat", + Speed: 40, + SpeechColor: color.RGBA{200, 200, 255, 255}, + W: 34, + H: 20, + }) +} diff --git a/domain/character.player.go b/domain/character.player.go new file mode 100644 index 0000000..b6a2d47 --- /dev/null +++ b/domain/character.player.go @@ -0,0 +1,18 @@ +package domain + +import ( + "image/color" + + p "git.teletypegames.org/games/pncdsl" +) + +func definePlayer(g *p.Game) { + g.CharacterManager.Register(p.Character{ + Name: "player", + Sprite: "spr/player", + Speed: 80, + SpeechColor: color.RGBA{255, 230, 160, 255}, + W: 28, + H: 62, + }) +} diff --git a/domain/dialog.cat_morning.go b/domain/dialog.cat_morning.go new file mode 100644 index 0000000..36934f5 --- /dev/null +++ b/domain/dialog.cat_morning.go @@ -0,0 +1,45 @@ +package domain + +import p "git.teletypegames.org/games/pncdsl" + +func defineCatMorning(g *p.Game) { + g.DialogueManager.Register(p.Dialogue{ + Name: "cat_morning", + Start: "start", + Nodes: []p.DialogueNode{ + { + Name: "start", + Lines: []p.DialogueLine{ + {Speaker: "cat", Text: "Mióóóóóóóóu. Késő van."}, + }, + Choices: []p.DialogueChoice{ + { + Text: "Mindjárt megy a kávé.", + Actions: []p.Action{p.SetFlag(FlagPromisedCoffee), p.EndDialogue()}, + }, + { + Text: "Te etted meg a babot?", + Show: p.Not(p.Flag(FlagCupboardOpen)), + Actions: []p.Action{p.GotoNode("beans")}, + }, + { + Text: "Hagyj békén.", + Actions: []p.Action{p.EndDialogue()}, + }, + }, + }, + { + Name: "beans", + Lines: []p.DialogueLine{ + {Speaker: "cat", Text: "A szekrényben van. Mindig ott szokott lenni."}, + }, + Choices: []p.DialogueChoice{ + { + Text: "Köszi.", + Actions: []p.Action{p.EndDialogue()}, + }, + }, + }, + }, + }) +} diff --git a/domain/domain.asset.go b/domain/domain.asset.go new file mode 100644 index 0000000..6d5bd71 --- /dev/null +++ b/domain/domain.asset.go @@ -0,0 +1,31 @@ +package domain + +import p "git.teletypegames.org/games/pncdsl" + +// registerAssets declares every asset the game references. Files don't +// need to exist on disk — the library will substitute deterministic +// colored placeholders for anything missing. +func registerAssets(g *p.Game) { + imgs := []string{ + "bg/bedroom", "bg/kitchen", + "spr/key", "spr/beans", "spr/mug", + "spr/player", "spr/cat", + } + for _, name := range imgs { + g.AssetManager.Register(p.Asset{ + Name: name, + Path: "assets/" + name + ".png", + Kind: p.AssetImage, + }) + } + audios := []string{ + "mus/wakeup", "mus/calm", "snd/coffee_done", + } + for _, name := range audios { + g.AssetManager.Register(p.Asset{ + Name: name, + Path: "assets/" + name + ".ogg", + Kind: p.AssetAudio, + }) + } +} diff --git a/domain/domain.flag.go b/domain/domain.flag.go new file mode 100644 index 0000000..e924f36 --- /dev/null +++ b/domain/domain.flag.go @@ -0,0 +1,10 @@ +package domain + +const ( + FlagKeyTaken = "key_taken" + FlagCupboardOpen = "cupboard_open" + FlagMugTaken = "mug_taken" + FlagCoffeeHasBeans = "coffee_has_beans" + FlagCoffeeHasMug = "coffee_has_mug" + FlagPromisedCoffee = "promised_coffee" +) diff --git a/domain/game.go b/domain/game.go new file mode 100644 index 0000000..f01e159 --- /dev/null +++ b/domain/game.go @@ -0,0 +1,46 @@ +package domain + +import p "git.teletypegames.org/games/pncdsl" + +// Build assembles the full Reggeli Kávé game by registering every entity +// into its matching manager on a fresh *Game. The order matters only for +// readability — Validate() runs after Build to cross-check references. +func Build() *p.Game { + g := p.NewGame("Reggeli Kávé", 320, 200) + + registerAssets(g) + + definePlayer(g) + defineCat(g) + + defineKey(g) + defineBeans(g) + defineMug(g) + + defineCatMorning(g) + + defineIntroScript(g) + defineVictoryScript(g) + + defineBedroom(g) + defineKitchen(g) + + // Story-rich HUD: top bar + NPC character panel + chat log + permanent + // verb wheel + small inventory. The player panel is skipped — the + // player avatar is always visible in the scene, so the floating card + // in the corner just gets in the way. Pass "player" as the second + // arg to put it back. + p.RegisterRichUI(g, "", "cat") + g.MaxLogLines = 64 + + // initial HUD vars + g.State.SetVar("score", 0) + g.State.SetVar("time", "Nap 1 - 07:23") + g.State.SetVar("player.state", "Ébren") + g.State.SetVar("player.mood", "Álmos") + g.State.SetVar("cat.state", "Várakozik") + g.State.SetVar("cat.mood", "Türelmetlen") + + g.StartAt("bedroom").OnStart(p.RunScript("intro")) + return g +} diff --git a/domain/item.beans.go b/domain/item.beans.go new file mode 100644 index 0000000..ae5071e --- /dev/null +++ b/domain/item.beans.go @@ -0,0 +1,11 @@ +package domain + +import p "git.teletypegames.org/games/pncdsl" + +func defineBeans(g *p.Game) { + g.ItemManager.Register(p.Item{ + Name: "beans", + Sprite: "spr/beans", + Description: "őrölt kávébab", + }) +} diff --git a/domain/item.key.go b/domain/item.key.go new file mode 100644 index 0000000..8b670cc --- /dev/null +++ b/domain/item.key.go @@ -0,0 +1,20 @@ +package domain + +import p "git.teletypegames.org/games/pncdsl" + +func defineKey(g *p.Game) { + g.ItemManager.Register(p.Item{ + Name: "key", + Sprite: "spr/key", + Description: "rozsdás kulcs", + OnUseWith: map[string]p.Action{ + "cupboard": p.Seq( + p.Say("player", "Klikk."), + p.SetFlag(FlagCupboardOpen), + p.Give("beans"), + p.TakeAway("key"), + p.Say("player", "Bab van benne. Pont, ami kell."), + ), + }, + }) +} diff --git a/domain/item.mug.go b/domain/item.mug.go new file mode 100644 index 0000000..0395968 --- /dev/null +++ b/domain/item.mug.go @@ -0,0 +1,11 @@ +package domain + +import p "git.teletypegames.org/games/pncdsl" + +func defineMug(g *p.Game) { + g.ItemManager.Register(p.Item{ + Name: "mug", + Sprite: "spr/mug", + Description: "kedvenc bögréje", + }) +} diff --git a/domain/scene.bedroom.go b/domain/scene.bedroom.go new file mode 100644 index 0000000..72aead4 --- /dev/null +++ b/domain/scene.bedroom.go @@ -0,0 +1,61 @@ +package domain + +import p "git.teletypegames.org/games/pncdsl" + +func defineBedroom(g *p.Game) { + g.SceneManager.Register(p.Scene{ + Name: "bedroom", + Title: "Hálószoba", + Background: "bg/bedroom", + Music: "mus/wakeup", + Actors: []p.SceneActor{ + {CharacterName: "player", At: p.Point{X: 160, Y: 145}}, + }, + Hotspots: []p.Hotspot{ + { + Name: "bed", + Area: p.Rect(20, 70, 90, 60), + Label: "ágy", + OnLook: p.Say("player", "A párnám még meleg."), + OnUse: p.Say("player", "Most keltem fel. Nem alszom vissza."), + }, + { + Name: "nightstand", + Area: p.Rect(115, 80, 35, 50), + Label: "éjjeliszekrény", + OnLook: p.If(p.Flag(FlagKeyTaken), + p.Say("player", "Üres a tetején."), + p.Say("player", "Egy rozsdás kulcs az éjjeliszekrényemen."), + ), + OnTake: p.If(p.Flag(FlagKeyTaken), + p.Say("player", "Már elvittem."), + p.Seq( + p.Walk("player", p.Point{X: 130, Y: 145}), + p.Give("key"), + p.SetFlag(FlagKeyTaken), + p.Say("player", "Pont jól jöhet."), + ), + ), + OnUse: p.If(p.Flag(FlagKeyTaken), + p.Say("player", "Már elvittem a kulcsot."), + p.Seq( + p.Walk("player", p.Point{X: 130, Y: 145}), + p.Give("key"), + p.SetFlag(FlagKeyTaken), + p.Say("player", "Megvan a kulcs."), + ), + ), + }, + { + Name: "door", + Area: p.Rect(260, 50, 40, 90), + Label: "ajtó", + OnLook: p.Say("player", "Az ajtó a konyhába vezet."), + OnUse: p.Seq( + p.Walk("player", p.Point{X: 260, Y: 145}), + p.GoTo("kitchen"), + ), + }, + }, + }) +} diff --git a/domain/scene.kitchen.go b/domain/scene.kitchen.go new file mode 100644 index 0000000..d834662 --- /dev/null +++ b/domain/scene.kitchen.go @@ -0,0 +1,115 @@ +package domain + +import p "git.teletypegames.org/games/pncdsl" + +func defineKitchen(g *p.Game) { + g.SceneManager.Register(p.Scene{ + Name: "kitchen", + Title: "Konyha", + Background: "bg/kitchen", + Music: "mus/calm", + Actors: []p.SceneActor{ + {CharacterName: "player", At: p.Point{X: 60, Y: 145}}, + {CharacterName: "cat", At: p.Point{X: 215, Y: 142}}, + }, + Hotspots: []p.Hotspot{ + { + Name: "cupboard", + Area: p.Rect(30, 40, 80, 80), + Label: "szekrény", + OnLook: p.Say("player", "Konyhaszekrény. Zárva."), + OnUse: p.If(p.Flag(FlagCupboardOpen), + p.Say("player", "Már nyitva van."), + p.If(p.HasItem("key"), + p.Seq( + p.Walk("player", p.Point{X: 70, Y: 145}), + p.Say("player", "Klikk."), + p.SetFlag(FlagCupboardOpen), + p.Give("beans"), + p.TakeAway("key"), + ), + p.Say("player", "Zárva. Kéne egy kulcs."), + ), + ), + OnUseWith: map[string]p.Action{ + "key": p.Seq( + p.Walk("player", p.Point{X: 70, Y: 145}), + p.Say("player", "Klikk."), + p.SetFlag(FlagCupboardOpen), + p.Give("beans"), + p.TakeAway("key"), + ), + }, + }, + { + Name: "shelf", + Area: p.Rect(115, 45, 35, 50), + Label: "polc", + OnLook: p.Say("player", "A polc tele bögrékkel."), + OnTake: p.If(p.Flag(FlagMugTaken), + p.Say("player", "Tiszta már mind elfogyott."), + p.Seq( + p.Walk("player", p.Point{X: 125, Y: 145}), + p.Give("mug"), + p.SetFlag(FlagMugTaken), + p.Say("player", "Egy bögre, kérem."), + ), + ), + OnUse: p.If(p.Flag(FlagMugTaken), + p.Say("player", "Már elvettem egyet."), + p.Seq( + p.Walk("player", p.Point{X: 125, Y: 145}), + p.Give("mug"), + p.SetFlag(FlagMugTaken), + p.Say("player", "Egy bögre, kérem."), + ), + ), + }, + { + Name: "coffee_machine", + Area: p.Rect(160, 75, 50, 55), + Label: "kávéfőző", + OnLook: p.Say("player", "A jó öreg kávéfőző."), + OnUse: p.If(p.And(p.Flag(FlagCoffeeHasBeans), p.Flag(FlagCoffeeHasMug)), + p.RunScript("victory"), + p.Say("player", "Még hiányzik valami. Bab? Bögre?"), + ), + OnUseWith: map[string]p.Action{ + "beans": p.Seq( + p.Walk("player", p.Point{X: 180, Y: 145}), + p.SetFlag(FlagCoffeeHasBeans), + p.TakeAway("beans"), + p.Say("player", "Bab a helyén."), + p.If(p.And(p.Flag(FlagCoffeeHasBeans), p.Flag(FlagCoffeeHasMug)), + p.RunScript("victory")), + ), + "mug": p.Seq( + p.Walk("player", p.Point{X: 180, Y: 145}), + p.SetFlag(FlagCoffeeHasMug), + p.TakeAway("mug"), + p.Say("player", "Bögre a helyén."), + p.If(p.And(p.Flag(FlagCoffeeHasBeans), p.Flag(FlagCoffeeHasMug)), + p.RunScript("victory")), + ), + }, + }, + { + Name: "cat", + Area: p.Rect(195, 118, 35, 22), + Label: "Cirmos", + OnLook: p.Say("player", "Cirmos, a házikedvencem."), + OnTalk: p.RunDialogue("cat_morning"), + }, + { + Name: "door", + Area: p.Rect(0, 40, 22, 90), + Label: "ajtó", + OnLook: p.Say("player", "Vissza a hálóba."), + OnUse: p.Seq( + p.Walk("player", p.Point{X: 20, Y: 145}), + p.GoTo("bedroom"), + ), + }, + }, + }) +} diff --git a/domain/script.intro.go b/domain/script.intro.go new file mode 100644 index 0000000..c8c710b --- /dev/null +++ b/domain/script.intro.go @@ -0,0 +1,16 @@ +package domain + +import p "git.teletypegames.org/games/pncdsl" + +func defineIntroScript(g *p.Game) { + g.ScriptManager.Register(p.Script{ + Name: "intro", + Actions: p.Seq( + p.Wait(0.4), + p.Say("player", "Brr, hideg van."), + p.Say("player", "Egy kávé kéne, mielőtt szétszakad a fejem."), + p.Walk("player", p.Point{X: 200, Y: 145}), + p.SetVar("player.mood", "Eltökélt"), + ), + }) +} diff --git a/domain/script.victory.go b/domain/script.victory.go new file mode 100644 index 0000000..6c4c2ec --- /dev/null +++ b/domain/script.victory.go @@ -0,0 +1,20 @@ +package domain + +import p "git.teletypegames.org/games/pncdsl" + +func defineVictoryScript(g *p.Game) { + g.ScriptManager.Register(p.Script{ + Name: "victory", + Actions: p.Seq( + p.Say("player", "Készen is van!"), + p.PlaySound("snd/coffee_done"), + p.Wait(0.6), + p.Say("cat", "Mióóóóu. *boldog macska*"), + p.Say("player", "Reggeli kávé: megmentve."), + p.SetVar("score", 100), + p.SetVar("player.mood", "Boldog"), + p.SetVar("cat.mood", "Boldog"), + p.ShowEnd("Vége — kösz, hogy játszottál!"), + ), + }) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..7404a12 --- /dev/null +++ b/go.mod @@ -0,0 +1,17 @@ +module git.teletypegames.org/games/pncdsl-demo + +go 1.26.3 + +require git.teletypegames.org/games/pncdsl v0.0.0-00010101000000-000000000000 + +require ( + github.com/ebitengine/gomobile v0.0.0-20250923094054-ea854a63cce1 // indirect + github.com/ebitengine/hideconsole v1.0.0 // indirect + github.com/ebitengine/purego v0.9.0 // indirect + github.com/hajimehoshi/ebiten/v2 v2.9.9 // indirect + github.com/jezek/xgb v1.1.1 // indirect + golang.org/x/sync v0.17.0 // indirect + golang.org/x/sys v0.36.0 // indirect +) + +replace git.teletypegames.org/games/pncdsl => ../pncdsl diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..03c113f --- /dev/null +++ b/go.sum @@ -0,0 +1,16 @@ +github.com/ebitengine/gomobile v0.0.0-20250923094054-ea854a63cce1 h1:+kz5iTT3L7uU+VhlMfTb8hHcxLO3TlaELlX8wa4XjA0= +github.com/ebitengine/gomobile v0.0.0-20250923094054-ea854a63cce1/go.mod h1:lKJoeixeJwnFmYsBny4vvCJGVFc3aYDalhuDsfZzWHI= +github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj1yReDqE= +github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A= +github.com/ebitengine/purego v0.9.0 h1:mh0zpKBIXDceC63hpvPuGLiJ8ZAa3DfrFTudmfi8A4k= +github.com/ebitengine/purego v0.9.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/hajimehoshi/ebiten/v2 v2.9.9 h1:JdDag6Ndj12iD4lxQGG8kbsrh7ssj4Sbzth6r929H/M= +github.com/hajimehoshi/ebiten/v2 v2.9.9/go.mod h1:DAt4tnkYYpCvu3x9i1X/nK/vOruNXIlYq/tBXxnhrXM= +github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4= +github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk= +golang.org/x/image v0.31.0 h1:mLChjE2MV6g1S7oqbXC0/UcKijjm5fnJLUYKIYrLESA= +golang.org/x/image v0.31.0/go.mod h1:R9ec5Lcp96v9FTF+ajwaH3uGxPH4fKfHHAVbUILxghA= +golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= +golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= +golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= diff --git a/main.go b/main.go new file mode 100644 index 0000000..70ecec7 --- /dev/null +++ b/main.go @@ -0,0 +1,14 @@ +package main + +import ( + "log" + + "git.teletypegames.org/games/pncdsl-demo/domain" + "git.teletypegames.org/games/pncdsl" +) + +func main() { + if err := pncdsl.Run(domain.Build()); err != nil { + log.Fatal(err) + } +}