46 lines
1.9 KiB
Text
46 lines
1.9 KiB
Text
design (+ usage)
|
|
|
|
(this is for now just a design document and not describing the actual program.)
|
|
|
|
slutpet makes use of s7 scheme as a scripting language.
|
|
(this, by the way, is why the program takes a weirdly long time to compile --
|
|
s7.{c,h} contain the entire s7 scheme interpreter, over 100,000 lines.)
|
|
if you don't know scheme,
|
|
a) don't worry, it's pretty simple, and
|
|
b) sorry in advance.
|
|
|
|
c source files:
|
|
|
|
sp.c: main entry, exit, event/render loops
|
|
|
|
a pet is implemented by setting the variable 'pet' to
|
|
an alist (is this the correct term?) which contains some values.
|
|
setting the pet variable should handle this automatically,
|
|
but various hooks can then be set, which will be executed
|
|
whenever a certain event has happened.
|
|
|
|
list of variables:
|
|
pet: the pet that the program will use. this is a list of cons that define the pet.
|
|
TODO: maybe this should be a macro that sets other variables.
|
|
|
|
pet-name: string containing the pet's name.
|
|
|
|
list of hooks:
|
|
pre-init-hook: before anything has happened at all; right after s7 has been initialised.
|
|
this is also before any init files have been read
|
|
post-init-hook: when the window has been set up and things are ready to happen.
|
|
the current pet should be set and initialised by this point.
|
|
tick-hook: every program tick. the pet's drawing information should be set
|
|
here so it can be rendered.
|
|
TODO: figure out what to do about event hooks
|
|
pre-quit-hook: the program is about to exit, no de-init things have been done yet.
|
|
post-quit-hook: everything (except, obviously, the s7 interpreter) has been de-initialised.
|
|
|
|
list of functions:
|
|
(load-image path): set up a new image, with the data taken from the given path.
|
|
this will return the a list of cons pairs with the image data,
|
|
in a form that can be used in the pet variable.
|
|
(free-image image): free heap-allocated data in image.
|
|
|
|
list of c-types:
|
|
pixmap: the data created from stb-image.
|