API reference¶
Entry point¶
cl-sl:run (&key (width +default-width+) (height +default-height+) accident-p little-p fly-p (fps 20) (stream *standard-output*))-- runs the locomotive across the real terminal until it fully scrolls off the left edge, orq/Ctrl-C is pressed early.accident-p/little-p/fly-pselect the-a/-l/-Fvariants (seemake-world);fpsis forwarded tocl-tty-kit:tick-loop-run-realtimeas its tick interval.
Train¶
cl-sl:make-train (&key (x 0.0) (dx -2.0) (variant :normal))--variantis one of:normal,:little,:fly(see+train-variants+); signalsunknown-variantfor anything else.cl-sl:train-advance (train)-- the pure per-tick transition: moves, animates, and counts down an active collision pause.cl-sl:train-art,cl-sl:train-width,cl-sl:train-height,cl-sl:train-baseline-y,cl-sl:train-y,cl-sl:train-exited-p.- State accessors:
cl-sl:train-x,cl-sl:train-dx,cl-sl:train-variant,cl-sl:train-frame-index,cl-sl:train-collision-state,cl-sl:train-collision-ttl,cl-sl:train-fly-tick.
World¶
cl-sl:make-world (&key (width +default-width+) (height +default-height+) accident-p little-p fly-p (speed -2.0))-- signalsinvalid-dimensionsfor a non-positive width or height.-F/-lresolve tovariantthe same wayrun's do;-Fwins when bothlittle-pandfly-pare true.cl-sl:world-advance (world)-- one pure simulation tick.cl-sl:world-resize (world width height).cl-sl:world-quitp (world)-- true once the train has fully left the screen, orq/Ctrl-C was pressed.cl-sl:world-apply-key-event/cl-sl:world-apply-key-events.- State accessors:
cl-sl:world-width,cl-sl:world-height,cl-sl:world-tick,cl-sl:world-train,cl-sl:world-accident-p,cl-sl:world-person-x,cl-sl:world-person-struck-p,cl-sl:world-quit-requested.
Collision¶
cl-sl:train-strikes-person-p (world),cl-sl:apply-collision (world).
Rendering¶
cl-sl:draw-world (screen world),cl-sl:render-frame (renderer world).
Constants¶
cl-sl:+default-width+(80),cl-sl:+default-height+(24) --run's andmake-world's default terminal size when the caller does not pass one.cl-sl:+train-variants+-- the validmake-train/make-worldvariant keywords::normal,:little,:fly.
Conditions¶
See Conditions.