2023 Lisp Game Jam Entry
“Apple”
Apple is a reverse snake — you’re an apple trying to avoid the snake.
Dependencies
- chicken scheme (
csi
) with eggs:- matchable
- r7rs
- stty
- my ansi library, yolk
Running
Run ./apple.scm
in this directory. Alternatively, run make
to build a static binary and run that instead.
License
This software is licensed under the God Willing License, version 1.0. See COPYING for details.
Also, here is a picture of a cool rock I found:
Development log
2023-06-01
- Changed name to apple
Added a makefile for compilation
- I made the snake smart!
- now it follows the appple around the screen trying to eat it
- figuring out collision logic and making sure the snake didn’t eat itself and all was .. whoo boy, it was wild
- but in the end it works well enough!
- Added game win/lose conditions
- Added fruit
- will make that work tomorrow
- hacky AS HECK! here be dragons yall
- collision detection is full of special cases, and I don’t like how it works
2023-05-31
- Added color using the (yolk attrs) library
- Parameterize (me) and (snake) in main to make definition order unimportant
- Change game loop and event handling to allow for independent snake movement
- This didn’t require using threads!
- Also enabled hjkl for movement.
- The snake is very dumb right now — it just goes in a circle.
- Also includes timing!
- And changing direction!
- Randomly place snake and apple
- Refactor functions to pass around the world less
- This means that things now hold a reference to the world they’re in .. I think this makes sense
- Add checking if things are around a given thing
2023-05-30
- Changed license to LATCRIFPL
- Added beginning of snake and came up with basic idea for game
I’m going to have to add threads >_< Curse you non-turn-based games!
The snake is interesting … it’s its own structure with a head thing and a list of tail things trailing behind. Each time it moves it just cuts off its tail at the length it needs to be, giving the illusion of movement. I had some complicated stuff with each segment storing its own age … but that was a bad idea lol.
2023-05-29
- I’ve changed the basic logic from just throwing characters on the screen wherever to a vector-based approach. I thought there was a multiple-dimensional vector egg or something, but I apparently was mistaken. So I’m doing the ol’ multiply-by-one-thing-and-add-another approach.
- Implementing collision detection was slightly easier than I thought it might be.
- Figuring out the vector bounds math was tricky… lots of “off-by-one” errors. I suppose I’ve hit both of the main errors of computer science with this game, then.
- I encapsulated things in their own records (so far,
world
,thing
, andme
… andworld
andme
are parameterized) to keep stuff together. I think this’ll work… I hope!
.. before
I started out by writing yolk, which has a bunch of procedures returning strings for terminal escapes. NIH and all :)
Originally I had a big loop to just draw all the border stuff at once, then the character where I wanted it. The character would erase itself and redraw as it moved, which worked fine … for one object.
I was walking around when I realized I’d need to redo things.