Get the latest tech news
Show HN: I implemented Snake in a tmux config file
Honestly I’d stop if I could, but I just get carried away. After making a compiler for tmux, then solving sudoku, then playing video I wasn’t planning on making a game. These things just happen to you. Well maybe not to you, but they happen to me. Unlike the video player, this isn’t just rendering Snake inside tmux. The entire game—input, game logic, and rendering—is done using tmux config files. You just load tmux with this config, and you’ll have...
In the end I only needed a single keybinding, which steps the game forward one iteration and schedules the next frame using run -d: This first section moves the head, stored as a separate variable to the rest of the body so it’s easier to keep track of and handle collisions. By keeping track of the length of the snake and how many iterations there have been, I just lookup what the position was N steps ago, and swap that square back.
Or read this on Hacker News