spook

A "game" for the 2023 Autumn Lisp Game Jam. Won first place! (from the bottom...)
git clone https://kaka.farm/~git/spook
Log | Files | Refs | LICENSE

cells.scm (681B)


      1 ;;;; cells.scm
      2 
      3 
      4 (define w 30)
      5 (define h 30)
      6 
      7 (define cells (make-array (shape 0 w 0 h)))
      8 (define col #t)
      9 
     10 (define (create)
     11   (do ((x 0 (+ x 1)))
     12       ((>= x w))
     13     (do ((y 0 (+ y 1)))
     14 	((>= y h))
     15       (let ((div ((native document.createElement) "div")))
     16 	(array-set! cells x y div)
     17 	(set! (.style.left div) (string-append (number->string (+ (* x 5) 50)) "px"))
     18 	(set! (.style.top div) (string-append (number->string (+ (* y 5) 50)) "px"))
     19 	(set! (.stype.backgroundColor div) (if col "red" "green"))
     20 	(set! (.stype.position div) "absolute")
     21 	(set! (.stype.width div) 5)
     22 	(set! (.stype.height div) 5)
     23 	(set! col (not col))
     24 	((native document.body.appendChild) div)))))
     25 
     26 (create)