Page:
Playing a Game
Pages
2D Drawing
2D Nodes
Code Edits
Code Services
Containers
Control Input
Engines
Exporting
File System Dock
Getting Started
Home
Input and Actions
Lisp Text
Live Pipelines
Painters
Playing a Game
Popups Menus and Dialogs
Popups and Dialogs
Project Manager
Projects
Render Targets
Resources
Saving Scenes
Scene Tree
Script Screen
Sessions
Signals
Status
The Debugger
The Editor
The REPL
Themes
Tweens
Undo and Redo
User Interface
Widgets
No results
2
Playing a Game
dxtr edited this page 2026-10-19 08:16:58 +02:00
Table of Contents
Playing a Game
The system pyssel/play plays a saved scene as a game in your Lisp, as
Pyssel's editor plays one: in an engine of its own, with its own render
thread, GPU device and job pool, and a session of its own,
while your REPL goes on. The game loads its code from an ASDF system, so
put the arena's definitions of Saving Scenes, from
defpackage to cheer, in
arena.lisp, beside arena.asd:
(defsystem "arena"
:depends-on ("pyssel/scene-2d")
:components ((:file "arena")))
Then, with arena.scene saved as that page saves it:
(asdf:load-system :pyssel/play)
(asdf:load-system :arena)
(defvar *play* (pyssel/play:play :scene "arena.scene" :system :arena :title "Arena"))
;; Playing arena.scene in this Lisp.
The arena opens in a window of its own. In a project,
(pyssel/play:play) plays its main scene, with its settings.
- The game's objects are yours:
play-treeis its scene tree, whose nodes you reach withcall-in-treeorsend-to-tree, and code you compile redefines the game's, as it plays. - Its threads' bindings:
play's:bindings, as((symbol value) ...), are more variables the game's threads bind, as the editor binds the hook its debugger takes their errors with; the play's own, its session and output streams, win over them. - Each play starts afresh:
playloads the game's system again, so the files you changed are compiled, and gives the gameplay-session, a session of its own, which its scene is loaded in and its threads have. What it loads, and changes in its resources and its default theme, is its own, and the next play loads them anew. - Global variables are the one thing a play shares with you and the
plays after it. When a play ends,
play-changed-variablesnames those of the game's package, the one named as its system is, or of the:packagesyou give, whose values it changed, and the output says so. Keep a game's state in its nodes and resources. - Its output and errors: what the game writes goes to
:output, by default where you calledplay. An error in a node's callback stops the node, with a warning there, and the game goes on; one that reaches the debugger, such as an error in the engine's own drawing, waits in SLY's, or for a game the editor plays, in its Debugger dock, on the game's render thread, which stops the game's frames and nothing else. - Stopping: close the window, have a node call
(sc:quit), or(stop-play *play*). A game that does not stop within five seconds, being stuck in a loop of its own code or waiting in the debugger, makesstop-playsignalplay-not-responding, with the restartswait-longer;break-into-play, which breaks into the game's render thread with the debugger, asbreak-into-enginedoes, where you see what it does and choosestop-engine; andabandon-play, which lets it go, its threads staying until your Lisp ends. It is never unwound from outside, since an interrupt may land in foreign code.
Getting started
The core
Drawing
Scenes
User interface
Games and the editor
- Playing a Game
- Projects
- The Editor
- The File System Dock
- The Script Screen
- The REPL
- The Debugger
- Lisp Text
- Code Services
- Project Manager
- Undo and Redo
- Exporting
The project