This commit is contained in:
2026-05-25 23:17:33 +02:00
parent d74acc58de
commit 7b22f0d4a7
6 changed files with 87 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ func Build() *p.Game {
// in the corner just gets in the way. Pass "player" as the second
// arg to put it back.
p.RegisterRichUI(g, "", "cat")
g.UIManager.Register(&saveKeys{})
g.MaxLogLines = 64
// initial HUD vars

View File

@@ -11,6 +11,17 @@ func defineBedroom(g *p.Game) {
Actors: []p.SceneActor{
{CharacterName: "player", At: p.Point{X: 160, Y: 145}},
},
// Floor strip — Walk targets get clipped to this band, so clicks
// on the bed or nightstand send the player to the floor in front
// of them instead of letting them clip through furniture.
Walkboxes: []p.Polygon{
p.Poly(
p.Point{X: 10, Y: 135},
p.Point{X: 310, Y: 135},
p.Point{X: 310, Y: 160},
p.Point{X: 10, Y: 160},
),
},
Hotspots: []p.Hotspot{
{
Name: "bed",

View File

@@ -12,6 +12,28 @@ func defineKitchen(g *p.Game) {
{CharacterName: "player", At: p.Point{X: 60, Y: 145}},
{CharacterName: "cat", At: p.Point{X: 215, Y: 142}},
},
// Floor strip. Same shape as the bedroom — keeps movement on a
// consistent Y band and clips destinations away from the cupboard
// and coffee machine.
Walkboxes: []p.Polygon{
p.Poly(
p.Point{X: 10, Y: 135},
p.Point{X: 310, Y: 135},
p.Point{X: 310, Y: 160},
p.Point{X: 10, Y: 160},
),
},
// First time the player walks into the kitchen with the key in
// hand, drop a hint. The trigger arms on scene enter; the
// rising-edge fires once per arming because Once: true.
Triggers: []p.Trigger{
{
Name: "kitchen_with_key_hint",
Once: true,
When: p.And(p.HasItem("key"), p.Not(p.Flag(FlagCupboardOpen))),
Do: p.Say("player", "A kulcs jól jöhet a szekrényhez."),
},
},
Hotspots: []p.Hotspot{
{
Name: "cupboard",

35
domain/widget.savekeys.go Normal file
View File

@@ -0,0 +1,35 @@
package domain
import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil"
p "git.teletypegames.org/games/pncdsl"
)
// saveKeys is a no-draw widget that binds F5 → Save(slot 0) and
// F9 → Load(slot 0). Errors are surfaced via FlashLine so the player
// sees them in the status strip.
type saveKeys struct{}
func (s *saveKeys) GetName() string { return "save_keys" }
func (s *saveKeys) Tick(ctx *p.UICtx) {
g := ctx.Game
if inpututil.IsKeyJustPressed(ebiten.KeyF5) {
if err := g.Save(0); err != nil {
g.FlashLine("Mentés hiba: " + err.Error())
} else {
g.FlashLine("Mentve (F5).")
}
}
if inpututil.IsKeyJustPressed(ebiten.KeyF9) {
if err := g.Load(0); err != nil {
g.FlashLine("Töltés hiba: " + err.Error())
} else {
g.FlashLine("Betöltve (F9).")
}
}
}
func (s *saveKeys) Draw(_ *ebiten.Image, _ *p.UICtx) {}