Skip to main content

std-puzzle-app

Level: Organism | Entity: PuzzleLevel | Persistence: runtime

4 states, 10 events, 12 transitions

Live Preview

;; app Puzzle App

orbital PuzzleLevelOrbital {
entity PuzzleLevel [runtime] {
id : string!
level : number
score : number
moves : number
completed : boolean
highScore : number
combo : number
multiplier : number
}
trait PuzzleLevelPuzzleFlow -> PuzzleLevel [interaction] {
initial: menu
state menu {
INIT -> menu
(fetch PuzzleLevel)
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "game-menu", title: "Puzzle Challenge", subtitle: "Puzzle Challenge", menuItems: [{ label: "Start Puzzle", event: "START", variant: "primary" }] }] })
START -> playing
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "game-canvas2-d", width: 800, height: 600, fps: 60 }] })
NAVIGATE -> menu
}
state playing {
MOVE -> playing
(set @entity.moves (+ @entity.moves 1))
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "game-canvas2-d", width: 800, height: 600, fps: 60 }] })
HINT -> playing
PAUSE -> paused
(render-ui modal { type: "game-menu", title: "Paused", menuItems: [{ label: "Resume", event: "RESUME", variant: "primary" }, { label: "Quit", event: "RESTART", variant: "ghost" }] })
GAME_OVER -> gameover
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "game-over-screen", title: "Puzzle Complete", stats: [{ label: "Score", value: "@entity.score" }, { label: "Moves", value: "@entity.moves" }], menuItems: [{ label: "Play Again", event: "RESTART", variant: "primary" }, { label: "Main Menu", event: "RESTART", variant: "secondary" }] }] })
}
state paused {
NAVIGATE -> paused
RESUME -> playing
(render-ui modal null)
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "game-canvas2-d", width: 800, height: 600, fps: 60 }] })
CLOSE -> playing
(render-ui modal null)
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "game-canvas2-d", width: 800, height: 600, fps: 60 }] })
RESTART -> menu
(render-ui modal null)
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "game-menu", title: "Puzzle Challenge", subtitle: "Puzzle Challenge", menuItems: [{ label: "Start Puzzle", event: "START", variant: "primary" }] }] })
}
state gameover {
RESTART -> menu
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "game-menu", title: "Puzzle Challenge", subtitle: "Puzzle Challenge", menuItems: [{ label: "Start Puzzle", event: "START", variant: "primary" }] }] })
}
}
trait PuzzleLevelPuzzleScore -> PuzzleLevel [interaction] {
state idle {
INIT -> idle
(fetch PuzzleLevel)
ADD_SCORE -> idle
(set @entity.score (+ @entity.score @payload.points))
(set @entity.combo (+ @entity.combo 1))
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "score-board", score: "@entity.score", highScore: "@entity.highScore", combo: "@entity.combo", multiplier: "@entity.multiplier", level: "@entity.level" }] })
COMBO -> idle
(set @entity.multiplier @payload.multiplier)
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "score-board", score: "@entity.score", highScore: "@entity.highScore", combo: "@entity.combo", multiplier: "@entity.multiplier", level: "@entity.level" }] })
RESET -> idle
(set @entity.score 0)
(set @entity.combo 0)
(set @entity.multiplier 1)
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "score-board", score: "@entity.score", highScore: "@entity.highScore", combo: "@entity.combo", multiplier: "@entity.multiplier", level: "@entity.level" }] })
}
}
page "/puzzle" -> PuzzleLevelPuzzleFlow, PuzzleLevelPuzzleScore
}
orbital PuzzleScoreOrbital {
entity PuzzleScore [runtime] {
id : string!
playerName : string!
score : number!
level : number
moves : number
highScore : number
combo : number
multiplier : number
}
trait PuzzleScoreScoreBoard -> PuzzleScore [interaction] {
state idle {
INIT -> idle
(fetch PuzzleScore)
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "score-board", score: "@entity.score", highScore: "@entity.highScore", combo: "@entity.combo", multiplier: "@entity.multiplier", level: "@entity.level" }] })
ADD_SCORE -> idle
(set @entity.score (+ @entity.score @payload.points))
(set @entity.combo (+ @entity.combo 1))
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "score-board", score: "@entity.score", highScore: "@entity.highScore", combo: "@entity.combo", multiplier: "@entity.multiplier", level: "@entity.level" }] })
COMBO -> idle
(set @entity.multiplier @payload.multiplier)
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "score-board", score: "@entity.score", highScore: "@entity.highScore", combo: "@entity.combo", multiplier: "@entity.multiplier", level: "@entity.level" }] })
RESET -> idle
(set @entity.score 0)
(set @entity.combo 0)
(set @entity.multiplier 1)
(render-ui main { type: "game-shell", appName: "Puzzle App", showTopBar: true, children: [{ type: "score-board", score: "@entity.score", highScore: "@entity.highScore", combo: "@entity.combo", multiplier: "@entity.multiplier", level: "@entity.level" }] })
}
}
page "/scores" -> PuzzleScoreScoreBoard
}
Loading preview...

Orbital Visualization

Loading visualization...

Entity Fields

FieldTypeDefault
idstring-
levelnumber1
scorenumber0
movesnumber0
completedbooleanfalse
highScorenumber0
combonumber0
multipliernumber1

States

StateType
menuInitial
playing-
paused-
gameover-

Events

EventPayload
INIT-
START-
MOVE-
HINT-
PAUSE-
RESUME-
GAME_OVER-
RESTART-
CLOSE-
NAVIGATE-

Transitions

FromEventToEffects
menuINITmenu2 effects
menuSTARTplaying1 effect
playingMOVEplaying2 effects
playingHINTplaying-
menuNAVIGATEmenu-
pausedNAVIGATEpaused-
playingPAUSEpaused1 effect
pausedRESUMEplaying2 effects
pausedCLOSEplaying2 effects
playingGAME_OVERgameover1 effect
gameoverRESTARTmenu1 effect
pausedRESTARTmenu2 effects