Posted May 30, 2023 by screwtape
#lisp-game-jam #CommonLisp #EmbeddableCommonLisp #Video #Style #Exploratory-style #game #programming
Video of LISP programming over on the 'stodon https://mastodon.sdf.org/@screwtape/110456458306869225 since I can't upload a video here.
FINALLY made it to LISP for my LISP GAME JAM and I could not be happier. HACKNEYED C GAME JAM NO LONGER
Basically done, just gotta put robots and puzzles in.
The actual phost mirror (pst, don't tell the other gophers that I shared a video with you and not them on the 'stodon )
Phost web mirror: https://gopher.floodgap.com/gopher/gw.lite?=tilde.institute+70+302f7e73637265777...
Source web mirror: https://gopher.floodgap.com/gopher/gw.lite?=tilde.institute+70+312f7e73637265777...
Little by little !
FINALLY actually JAMMING and in LISP
Now I can work on the game by programming in lisp. Let's go through
#'make-game, which is just a record of hacking along in a repl,
dumping often flawed defs from a source editor.
; I added unwind-protect of SDL_Quit() which is safe. (defparameter *funs* (list)) (defun play-game () (game () () *funs*))
The game is whatever funs go in *funs*. (play-game) is a utility that
should probably be a symbol-macro.
Here, I push my line-drawer I wrote already in one direction, and run
the game
(push (draw-lines-from (coord-liner 0 (+ 2 (truncate 640 *scale*)) 1 0 (+ 1 (truncate 480 *scale*)) 1 :transpose nil) '(255 0 0)) *funs*) (play-game)
Add the other direction, marvel at it again:
(push (draw-lines-from (coord-liner 0 (+ 2 (truncate 480 *scale*)) 1 0 (+ 1 (truncate 640 *scale*)) 1 :transpose t) '(255 255 0)) *funs*) (play-game)
;;;Here I wrote pretty big special-scope singleton closures for the player and a base
;;;Trying them out (more than once in reality :D)
(push (lambda () (Funcall (ensure-player) :paint t)) *funs*) (push (lambda () (Funcall (ensure-base) :paint t)) *funs*) (play-game) ;;; Add movement to the player using the exposed keyboardstate. (push (lambda () (funcall (ensure-player) :move (cond ((not (zerop (get-key-state *down*))) 's) ((not (zerop (get-key-state *up*))) 'n) ((not (zerop (get-key-state *left*))) 'w) ((not (zerop (get-key-state *right*))) 'e)))) *funs*) (play-game) ;; (yay, we can walk around)... ;; I added a *plants* list and (spawn-plant-in x y w h) ;; and (advance-someplants lists-of-name1->name2->fractional/probability) ;; and paint-plants. (loop repeat 6 do (spawn-plant-in -5 -5 15 15)) ;;(print *plants*) (advance-some-plants '(leaves flower 7/10)) ;;(print *plants*) ;;Nconc so the plants are always on top ;;(I wanted to see the plants - but that's probably backwards right) (nconc *funs* (list (lambda () (paint-plants)))) (play-game) So I'm pretty happy with a live CL repl as my "map editor".
And it finally looks like we are doing something sensible ;p though
there is basically no sensible way to write a bunch of up-front-C, but
now I am very happy. The jam is almost over though! I had an
offline-busy couple days.