Next: Input Devices, Up: Kernel [Contents][Index]
At the very core of Chickadee there is an event loop. This loop, or
“kernel”, is responsible for ensuring that the game is updated at
the desired interval, handling input devices, 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.
#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.
A new graphical window will be opened with window-width x
window-height as its dimensions, window-title as its
title, and in fullscreen mode if window-fullscreen? is
#t
.
alpha
value. See the documentation for
run-game
for an explanation of this value.
backspace
.
ctrl
, alt
, and shift
.
#t
if this is a repeated press of the same key.
left
, middle
, or right
.
a
b
x
y
back
guide
start
left-stick
right-stick
left-shoulder
right-shoulder
dpad-up
dpad-down
dpad-left
dpad-right
left-x
left-y
right-x
right-y
trigger-left
trigger-right
The default behavior is to re-throw the error.
To stop the game loop, simply call abort-game
.
Stop the currently running Chickadee game loop.
The above explanation of the game loop was partially a lie. It’s true
that there is a game loop at the center of Chickadee, but
run-game
is not it’s true entry point. There exists an even
lower level procedure, run-game*
, in the (chickadee
game-loop)
module that run-game
uses under the hood.
On its own, run-game*
does not do very much at all. In order
to actually respond to input events, update game state, or render
output, the developer must provide an engine. run-game
is such
an engine, and it’s likely all a developer will need. However, what
if a developer wanted to use all of the useful Chickadee features to
make a terminal roguelike game instead? Chickadee doesn’t come with a
terminal rendering engine, but the developer could write one without
having to write their own core game loop.
Start the game loop. This procedure will not return until
abort-game
is called.
The core game loop is generic and requires four additional procedures to operate:
Return the number of milliseconds that have passed since the game loop was started.
Next: Input Devices, Up: Kernel [Contents][Index]