flan/test/programs/sand-headless.flan

34 lines
1.3 KiB
Plaintext

;;;; sand.flan's other half: N frames, no window, hash the grid.
;;;;
;;;; This is the version CI runs on native *and* wasm32, and it imports
;;;; sand.flan itself — window, raylib bindings, dev agent and all. It builds
;;;; for wasm32 anyway because the link follows what the program reaches:
;;;; nothing here calls into raylib, so no shim is compiled and no -lraylib is
;;;; passed, and the front-end's own functions are never emitted. sand.flan's
;;;; main is not exported, so the only main is this one.
;;;;
;;;; A package is a directory, except when it is a single .flan file named
;;;; outright — which is this, because sand.flan shares the repository root
;;;; with three other loose programs.
;;;;
;;;; The hash is a regression test only because the sequence is reproducible:
;;;; rand is a seeded PRNG written in Flan, so the same seed gives the same
;;;; grains in the same places on both targets (plan.org, RNG is ours).
(import sand "../../sand.fln")
(defconst frames 40)
(defn main [] i32
(rand-seed 20260910)
;; Four clouds, spread across the top, one per colour. Deterministic
;; positions: the mouse is what the interactive driver has and this does not.
(dotimes [i 4]
(sand/next-color)
(sand/paint-at 4 (* (+ i 1) (/ sand/cols 5))))
(dotimes [f frames]
(sand/step))
(print (sand/hash-grid))
(println "")
0)