Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/magnetrwn/some-ncurses-snakes
A collection of implementations of Snake in different programming languages, using ncurses.
https://github.com/magnetrwn/some-ncurses-snakes
ncurses ncurses-game ncurses-library ncurses-tui ncurses-ui
Last synced: about 1 month ago
JSON representation
A collection of implementations of Snake in different programming languages, using ncurses.
- Host: GitHub
- URL: https://github.com/magnetrwn/some-ncurses-snakes
- Owner: magnetrwn
- License: mit
- Created: 2023-09-15T18:37:08.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-19T18:49:32.000Z (over 1 year ago)
- Last Synced: 2023-09-19T21:41:09.613Z (over 1 year ago)
- Topics: ncurses, ncurses-game, ncurses-library, ncurses-tui, ncurses-ui
- Language: C
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Some `ncurses` Snakes!
**Developing a simple version of Snake in various programming languages!**
Each folder contains a version of the game Snake for terminal that interfaces with `ncurses` to provide the game UI, or some other library in case it's not available.
I thought of this idea to learn Go, but now I want to expand it a little, just to give it a touch of many different languages.
**Make sure to check the implementation-specific READMEs, not just this one!**
## Current Implementations
+ C
+ C++
+ That's it for now :smile:## C and C++ Version
The possible Snake algorithms I had thought of for the game were:
+ Store a list of snake node coordinates, direction, and next_direction
+ **Store a list of snake rotations and only the head coordinates, then draw backward and rotate when meeting rotation points**
+ Use a delayed tail approach, which moves the same as the head but after N steps and clears nodes instead of applying themSince C can be considered lower level than other popular languages, I wanted to make something a bit more interesting algorithmically, so I decided to implement the snake by using a linked list of rotations (the second one). This allows the program to use memory way more efficiently to store the Snake!
Inside the `c/` or `cpp/` folder. You can find a few sources, headers and build script for Snake. Just execute the script and run `snake` once complete!
Here is an Asciinema Demo of the C version (C++ is very similar):