Jennifer Academy

Code: A terminal game in Jennifer

Code for "A terminal game in Jennifer"

Every program runs on the released Jennifer 0.27.0 (jennifer, the default binary: the term library is not in jennifer-tiny). Run them from this folder; nothing else needs installing. snake.j writes snake.save here.

FileSlidesRun
snake.jthe whole talkjennifer run snake.j in a terminal (arrows or w a s d, q quits)
snake.j with a seedFood in a random placeSNAKE_SEED=7 jennifer run snake.j (the same food every game)
moves.txtEnd of input, Saving the high scoreSNAKE_SEED=7 jennifer run snake.j < moves.txt (one letter per tick, x goes straight)
reaction.jRaw keys with the term library, readByteTimeoutjennifer run reaction.j in a terminal
eof-poll.jEnd of inputprintf 'ab' | jennifer run eof-poll.j
eof-wait.jEnd of input (notes)printf 'ab' | timeout 5 jennifer run eof-wait.j (hangs after eof on 0.26.0, so the timeout ends it)
capture.pythe captured framespython3 capture.py snake-session.json

capture.py (Python 3, standard library only, Linux or macOS) starts a program in a pseudo-terminal, presses keys on a schedule and prints the screen as text. The sessions behind the slides:

  • snake-session.json: a game played with arrow keys (Real frames, What we build)
  • replay-session.json: the moves.txt replay (the score 4 save file)
  • reaction-session.json: a key pressed 0.26 s after GO!

Frames depend on timing, so a rerun of snake-session.json can differ by a cell or two; the replay is the same every time. To try the save file checks, edit snake.save (change the score, or the version to 2.0.0) and start the game again.

FileSize
LICENSE899 Braw
README.md1.6 KiBraw
capture.py3.3 KiBraw
eof-poll.j329 Braw
eof-wait.j349 Braw
moves.txt43 Braw
reaction-session.json159 Braw
reaction.j874 Braw
replay-session.json121 Braw
snake-session.json375 Braw
snake.j7.5 KiBraw