lisp game jam 2 - squeaky clean grid drawing edition
Rewlogged from my web mirror of my gopher phosting : https://gopher.floodgap.com/gopher/gw.lite?=tilde.institute+70+302f7e73637265777...
source: https://gopher.floodgap.com/gopher/gw.lite?=tilde.institute+70+312f7e73637265777...
I guess 60 characters is normal in the web? What ancient console has a 60 character limit?
Cleaned up a lot! I removed the variable sharing with C for the time being: Since I want to be making a game in lisp with just some OS-facing C gears grinding along in the background. I'm now using ECL's sffi:c-inline to call C functions, which is pass-by-value. Now the loop mapcs 'funcall to a list of closures #'game takes. I'm still going to use c-progn's shared variables, but in the future I am going to use them to capture information from SDL2 (events and pixels) into the lisp side instead of doing some logic in C. I started making xs and os (or xs and +s), but I just did the grid for now, with much clearer and more functional infrastructure. If I run out of time, I will just submit a gomoku game like emacs' since I have that grid. One reason I concentrated on using a list of functions is that instead of tapping away in vi, :sh $ ^rrlwr^M # = rlwrap previous rlwrap ecl > ^r(req^M^rre^M # = rlwrap previous (require "jam-no-theme") then (ja::xs&+s) running and running back to vi for editing like an unsophisticated language, I want to be adding and changing the list of functions being run smoothly while the game is running. I guess I will add a second thread to keep a repl available and a lock on that list. I think the code is already much prettier. I have a function that returns a closure returning (x1 y1 x2 y2)s or nils describing one direction of a rectangular grid, which could be transposed: (defun coord-liner (start-x below-x x-space y-start y-stop y-space &key (transpose nil) &aux (cur-x start-x)) " (coord-liner (start-x below-x x-space y-start y-stop y-space &key (transpose nil))) Return a closure that returns (x1 y1 x2 y2) or nil when it loops, or if transpose (y1 x1 y2 x2) " (lambda () (reduce 'append (mapcar (if transpose 'reverse 'identity) (if (< cur-x below-x) (prog1 (list (list (* cur-x x-space) (* y-start y-space)) (list (* cur-x x-space) (* y-stop y-space))) (incf cur-x)) (prog1 nil (setf cur-x start-x))))))) And another function that uses ffi:c-inline to make the color and drawing C closure: (defun draw-lines-from (fun rgb) " Calls SDL_SetRenderDrawColor and SDL_RenderDrawLine with rgb and on a list from fun. " (lambda () (loop for (x1 y1 x2 y2) = (funcall fun) for (r g b) = rgb while x1 do (ffi:c-inline (r g b 255) (:int :int :int :int) nil "SDL_SetRenderDrawColor(renderer, #0, #1, #2, #3)" :one-liner t) do (ffi:c-inline (x1 y1 x2 y2) (:int :int :int :int) nil "SDL_RenderDrawLine(renderer, #0, #1, #2, #3)" :one-liner t)))) So the game (= simple grid), with no currently C shared variables (well, renderer is visible) is: (defun xs&+s () " I was thinking of naughts and crosses, but ultimately I'm just drawing a grid. " (let* ((horiz-lines (draw-lines-from (coord-liner 1 5 50 1 4 50 :transpose nil) '(255 0 0))) (verti-lines (draw-lines-from (coord-liner 1 5 50 1 4 50 :transpose t) '(255 255 0))) (funs (list horiz-lines verti-lines))) (game () () funs))) Because my grid-cells are half-open, the direction of lines being drawn is one greater than the length of the direction being drawn in. Anyway, try it out yourself ;p By the way, is no-one using Shinmera's CL game engine? I thought that had a big version recently. *The crazy way the previous version of this game worked let some scoping magic happen: but I have just removed the want for that scoping for now.
Get jam-no-theme eat berries collect treasure could technically control robots
Download NowName your own price
jam-no-theme eat berries collect treasure could technically control robots
lisp-game-jam SDL2 ecl cross-platform game, feat. jam berries & no theme
Status | Released |
Author | screwtape |
Genre | Puzzle |
Tags | berries, common-lisp, embeddable-common-lisp, lisp, lisp-game-jam, Robots, sdl2 |
More posts
- GAMEPLAY VIDEO - LIVE REPROGRAMMING BOTSJun 13, 2023
- Check ecl building + sdl2 is working testsJun 05, 2023
- Done and done ! Post screenies of backgrounds you find plzJun 04, 2023
- Draft submission (can you check my linux binary)Jun 03, 2023
- Day 5 - Actual Lisp Game Jamming Finally!May 30, 2023
- Annotated ECL SDL2 lisp game jam so far!May 27, 2023
- Day 1 - ecl sdl2 unhygeinic update macros & drawing!May 27, 2023
Leave a comment
Log in with itch.io to leave a comment.