diff options
Diffstat (limited to 'manuals/chickadee/Kernel.html')
-rw-r--r-- | manuals/chickadee/Kernel.html | 65 |
1 files changed, 50 insertions, 15 deletions
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 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> -<!-- Copyright (C) 2017 David Thompson davet@gnu.org +<!-- Copyright (C) 2017, 2018, 2019 David Thompson davet@gnu.org Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 @@ -13,6 +13,8 @@ A copy of the license is also available from the Free Software Foundation Web site at http://www.gnu.org/licenses/fdl.html. +* Chickadee: (chickadee). Game programming toolkit for Guile. + The document was typeset with http://www.texinfo.org/ (GNU Texinfo). --> @@ -96,16 +98,16 @@ Next: <a href="Math.html#Math" accesskey="n" rel="next">Math</a>, Up: <a href="A <a name="Kernel-1"></a> <h3 class="section">2.1 Kernel</h3> -<p>At the very core of Chickadee, in the <code>(chickadee)</code> 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 <code>run-game</code> and -<code>abort-game</code> procedures are the entry and exit points to the -Chickadee game loop kernel. +<p>At the very core of Chickadee, in the <code>(chickadee game-loop)</code> +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 <code>run-game*</code> and <code>abort-game</code> procedures are the entry +and exit points to the Chickadee game loop kernel. </p> <p>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. <p>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 <code>(chickadee sdl)</code> module: -<code>run-game/sdl</code>. +this purpose in the <code>(chickadee)</code> module: <code>run-game</code>. </p> <dl> -<dt><a name="index-run_002dgame_002fsdl"></a>Procedure: <strong>run-game/sdl</strong> <em>[#:window-title "Chickadee!"] [#:window-width 640] [#:window-height 480] [#:window-fullscreen? <code>#f</code>] [#: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]</em></dt> +<dt><a name="index-run_002dgame-1"></a>Procedure: <strong>run-game</strong> <em>[#:window-title "Chickadee!"] [#:window-width 640] [#:window-height 480] [#:window-fullscreen? <code>#f</code>] [#: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]</em></dt> <dd> -<p>Run the Chickadee game loop using the SDL engine. +<p>Run the Chickadee game loop using the SDL engine in OpenGL mode. </p> <p>A new graphical window will be opened with <var>window-width</var> x <var>window-height</var> as its dimensions, <var>window-title</var> as its @@ -358,6 +359,40 @@ values are: </dd></dl> +<a name="Live-Coding"></a> +<h4 class="subsection">2.1.1 Live Coding</h4> + +<p>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. +</p> +<p>First, create a cooperative REPL server (It’s important to use Guile’s +cooperative REPL server instead of the standard REPL server in +<code>(system repl server)</code> to avoid thread synchronization issues): +</p> +<div class="example"> +<pre class="example">(use-modules (system repl coop-server)) + +(define repl (spawn-coop-repl-server)) +</pre></div> + +<p>Then, in the game loop’s update procedure, add this: +</p> +<div class="example"> +<pre class="example">(poll-coop-repl-server repl) +</pre></div> + +<p>To use the REPL, connect to it via port 37146. Telnet will do the +trick, but using the <a href="https://www.nongnu.org/geiser/">Geiser</a> +extension for Emacs is by far the best way to develop at the REPL with +Guile. Use <code>M-x connect-to-guile</code> to connect to the REPL server. +</p> +<p>Happy hacking! +</p> <hr> <div class="header"> <p> |