From 279f17ac0e1b3d019c2b294098e834d249376686 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 4 Jun 2019 20:49:16 -0400 Subject: Update chickadee manual. --- manuals/chickadee/Kernel.html | 65 +++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 15 deletions(-) (limited to 'manuals/chickadee/Kernel.html') diff --git a/manuals/chickadee/Kernel.html b/manuals/chickadee/Kernel.html index c298723..f6bfa9c 100644 --- a/manuals/chickadee/Kernel.html +++ b/manuals/chickadee/Kernel.html @@ -1,6 +1,6 @@ - @@ -96,16 +98,16 @@ Next: , Up:

2.1 Kernel

-

At the very core of Chickadee, in the (chickadee) module, lies -an event loop. This loop, or “kernel”, is responsible for ensuring -that the game is updated at the desired interval, rendering the -current state of the game world, and handling errors if they occur. -The kernel implements what is known as a “fixed timestep” game loop, -meaning that the game simulation will be advanced by a fixed interval -of time and will never vary from frame to frame, unlike some other -styles of game loops. The appropriately named run-game and -abort-game procedures are the entry and exit points to the -Chickadee game loop kernel. +

At the very core of Chickadee, in the (chickadee game-loop) +module, lies an event loop. This loop, or “kernel”, is responsible +for ensuring that the game is updated at the desired interval, +rendering the current state of the game world, and handling errors if +they occur. The kernel implements what is known as a “fixed +timestep” game loop, meaning that the game simulation will be +advanced by a fixed interval of time and will never vary from frame to +frame, unlike some other styles of game loops. The appropriately +named run-game* and abort-game procedures are the entry +and exit points to the Chickadee game loop kernel.

On its own, the kernel does not do very much at all. In order to actually respond to input events, update game state, or render output, @@ -164,13 +166,12 @@ behavior is to simply re-throw the error.

Since most users will want to write 2D/3D games with hardware accelerated graphics rendering, controlled via keyboard, mouse, or game controller, Chickadee comes with an easy to use engine just for -this purpose in the (chickadee sdl) module: -run-game/sdl. +this purpose in the (chickadee) module: run-game.

-
Procedure: run-game/sdl [#:window-title "Chickadee!"] [#:window-width 640] [#:window-height 480] [#:window-fullscreen? #f] [#:update-hz 60] [#:load] [#:update] [#:draw] [#:quit] [#:key-press] [#:key-release] [#:text-input] [#:mouse-press] [#:mouse-release] [#:mouse-move] [#:controller-add] [#:controller-remove] [#:controller-press] [#:controller-release] [#:controller-move] [#:error]
+
Procedure: run-game [#:window-title "Chickadee!"] [#:window-width 640] [#:window-height 480] [#:window-fullscreen? #f] [#:update-hz 60] [#:load] [#:update] [#:draw] [#:quit] [#:key-press] [#:key-release] [#:text-input] [#:mouse-press] [#:mouse-release] [#:mouse-move] [#:controller-add] [#:controller-remove] [#:controller-press] [#:controller-release] [#:controller-move] [#:error]
-

Run the Chickadee game loop using the SDL engine. +

Run the Chickadee game loop using the SDL engine in OpenGL mode.

A new graphical window will be opened with window-width x window-height as its dimensions, window-title as its @@ -358,6 +359,40 @@ values are:

+ +

2.1.1 Live Coding

+ +

One of the biggest appeals of any Lisp dialect is the ability to use +the “read-eval-print loop” (REPL for short) to build programs +iteratively and interactively while the program is running. However, +programs that run in an event loop and respond to user input (such as +a video game) require special care for this workflow to be pleasant. +Chickadee provides no built-in support for live coding, but it’s +fairly easy to hook up a special kind of REPL yourself. +

+

First, create a cooperative REPL server (It’s important to use Guile’s +cooperative REPL server instead of the standard REPL server in +(system repl server) to avoid thread synchronization issues): +

+
+
(use-modules (system repl coop-server))
+
+(define repl (spawn-coop-repl-server))
+
+ +

Then, in the game loop’s update procedure, add this: +

+
+
(poll-coop-repl-server repl)
+
+ +

To use the REPL, connect to it via port 37146. Telnet will do the +trick, but using the Geiser +extension for Emacs is by far the best way to develop at the REPL with +Guile. Use M-x connect-to-guile to connect to the REPL server. +

+

Happy hacking! +


-- cgit v1.2.3