Discuss Scratch

BookOwl
Scratcher
1000+ posts

Terminal Snake

I know that this is a better fit for MaC, but I figured that mostly ATers would be interested in this

I've recently created a version of Snake that runs in the terminal. I figured that you guys might like to try it out.

Features:
  • Runs in the terminal.
  • Uses Unicode box drawing characters to create the snake and play area.
  • Color!
  • If you are running on OS X/macOS, the thing that the snake eats is actually an apple.

Screenshots:



Todo:
  • Add highscores
  • Make it work on Windows
  • Different levels of difficulty

You can find instructions for installing it on Github

Last edited by BookOwl (Jan. 10, 2017 13:26:53)

birdoftheday
Scratcher
500+ posts

Terminal Snake

Cool. What kind of window is that? I can help make it run on Windows if you want.
BookOwl
Scratcher
1000+ posts

Terminal Snake

I was running it in Hyper, because that looks better in screenshots then Terminal.app.
The problem with getting it to run on Windows is that the underlying termbox library doesn't support Windows.
theonlygusti
Scratcher
1000+ posts

Terminal Snake

This looks like a really awesome project! I love that you added emojis as well xD

BookOwl wrote:

  • If you are running on OS X/MacOS, the thing that the snake eats is actually an apple.
Not that that should be “macOS”
_nix
Scratcher
1000+ posts

Terminal Snake

Well, it's written in Rust, so it must be good

edit:

birdoftheday wrote:

Cool. What kind of window is that? I can help make it run on Windows if you want.

hyper.js, maybe?

edit 2: It is good. I got 25, in a really small terminal window:


Last edited by _nix (Jan. 9, 2017 19:04:29)

birdoftheday
Scratcher
500+ posts

Terminal Snake

_nix wrote:

Well, it's written in Rust, so it must be good
- Hacker News
BookOwl
Scratcher
1000+ posts

Terminal Snake

theonlygusti wrote:

This looks like a really awesome project! I love that you added emojis as well xD
Thanks!

theonlygusti wrote:

BookOwl wrote:

  • If you are running on OS X/MacOS, the thing that the snake eats is actually an apple.
Not that that should be “macOS”
Fixed.

_nix wrote:

Well, it's written in Rust, so it must be good


_nix wrote:

edit:

birdoftheday wrote:

Cool. What kind of window is that? I can help make it run on Windows if you want.

hyper.js, maybe?

edit 2: It is good. I got 25, in a really small terminal window:

http://i.cubeupload.com/TwRBUc.png
Yes, it was running in a hyper.js terminal. Nice score!

Last edited by BookOwl (Jan. 10, 2017 13:32:24)

BookOwl
Scratcher
1000+ posts

Terminal Snake

I've updated the game to save your high scores.
Znapi
Scratcher
500+ posts

Terminal Snake

Looks great! It quits whenever I eat an apple though.
herohamp
Scratcher
1000+ posts

Terminal Snake

This is super cool
BookOwl
Scratcher
1000+ posts

Terminal Snake

Znapi wrote:

Looks great! It quits whenever I eat an apple though.
What OS are you on?
edit
I pushed a commit that should fix this. Can you please try recompiling with the new code and see if it is fixed?

Last edited by BookOwl (Jan. 11, 2017 00:59:21)

Znapi
Scratcher
500+ posts

Terminal Snake

BookOwl wrote:

Znapi wrote:

Looks great! It quits whenever I eat an apple though.
What OS are you on?
macOS Sierra, and Terminal.app.
BookOwl
Scratcher
1000+ posts

Terminal Snake

Znapi wrote:

BookOwl wrote:

Znapi wrote:

Looks great! It quits whenever I eat an apple though.
What OS are you on?
macOS Sierra, and Terminal.app.
Weird can you see if it works now?
Znapi
Scratcher
500+ posts

Terminal Snake

BookOwl wrote:

Znapi wrote:

BookOwl wrote:

Znapi wrote:

Looks great! It quits whenever I eat an apple though.
What OS are you on?
macOS Sierra, and Terminal.app.
Weird can you see if it works now?
I thought it was weird too, because you look like you are on the same system. I tried it again, but it did the same thing. Even weirder, now it is failing to build “termbox-sys”. Idk what I did but termbox doesn't like my machine. I'm guessing the issue is on my end now.

Last edited by Znapi (Jan. 11, 2017 02:49:53)

BookOwl
Scratcher
1000+ posts

Terminal Snake

Znapi wrote:

BookOwl wrote:

Znapi wrote:

BookOwl wrote:

Znapi wrote:

Looks great! It quits whenever I eat an apple though.
What OS are you on?
macOS Sierra, and Terminal.app.
Weird can you see if it works now?
I thought it was weird too, because you look like you are on the same system. I tried it again, but it did the same thing. Even weirder, now it is failing to build “termbox-sys”. Idk what I did but termbox doesn't like my machine. I'm guessing the issue is on my end now.
It shouldn't even have to build termbox-sys again. Can you post a screenshot of what happens when you try to build it?

If you just want to play it, you can get a built version of it here.

Edit:
I've pushed a new version to github that should fix all the crashing issues. Please try building again.

Last edited by BookOwl (Jan. 11, 2017 14:37:51)

Znapi
Scratcher
500+ posts

Terminal Snake

BookOwl wrote:

Znapi wrote:

BookOwl wrote:

Znapi wrote:

BookOwl wrote:

Znapi wrote:

Looks great! It quits whenever I eat an apple though.
What OS are you on?
macOS Sierra, and Terminal.app.
Weird can you see if it works now?
I thought it was weird too, because you look like you are on the same system. I tried it again, but it did the same thing. Even weirder, now it is failing to build “termbox-sys”. Idk what I did but termbox doesn't like my machine. I'm guessing the issue is on my end now.
It shouldn't even have to build termbox-sys again. Can you post a screenshot of what happens when you try to build it?

If you just want to play it, you can get a built version of it here.

Edit:
I've pushed a new version to github that should fix all the crashing issues. Please try building again.
It had to build it again because I decided to clone the repo that way I didn't just keep downloading ZIPs. Here's what it says when trying to build:
snake-rs znapi$ cargo build --release
Compiling fps_clock v1.0.0
Compiling num-integer v0.1.32
Compiling num-complex v0.1.35
Compiling rustc_version v0.1.7
Compiling termbox-sys v0.2.9
Build failed, waiting for other jobs to finish...
error: failed to run custom build command for `termbox-sys v0.2.9`
process didn't exit successfully: `/Users/znapi/Programming/snake-rs/target/release/build/termbox-sys-9fd4f9b8a499569c/build-script-build` (exit code: 101)
--- stdout
running: "git" "clone" "https://github.com/nsf/termbox" ".termbox"

--- stderr
fatal: destination path '.termbox' already exists and is not an empty directory.
thread 'main' panicked at 'assertion failed: cmd.stdout(Stdio::inherit()).stderr(Stdio::inherit()).status().unwrap().success()', /Users/znapi/.cargo/registry/src/github.com-1ecc6299db9ec823/termbox-sys-0.2.9/build.rs:86
note: Run with `RUST_BACKTRACE=1` for a backtrace.
I've tried searching for where .termbox is to manually delete it, but I haven't been able to find it, and I don't think it even exists. A quick google search didn't help at all.
EDO2012
Scratcher
100+ posts

Terminal Snake

Cool!
BookOwl
Scratcher
1000+ posts

Terminal Snake

OK, somehow when you installed this before it failed to clean up some temporary directories. The following commands should fix it:
$ cd /Users/znapi/.cargo/registry/src/github.com-1ecc6299db9ec823/termbox-sys-0.2.9/
$ rm -rf .termbox
Now try building again.
Znapi
Scratcher
500+ posts

Terminal Snake

BookOwl wrote:

OK, somehow when you installed this before it failed to clean up some temporary directories. The following commands should fix it:
$ cd /Users/znapi/.cargo/registry/src/github.com-1ecc6299db9ec823/termbox-sys-0.2.9/
$ rm -rf .termbox
Now try building again.
That worked, thanks! It works great now.
BookOwl
Scratcher
1000+ posts

Terminal Snake

Znapi wrote:

BookOwl wrote:

OK, somehow when you installed this before it failed to clean up some temporary directories. The following commands should fix it:
$ cd /Users/znapi/.cargo/registry/src/github.com-1ecc6299db9ec823/termbox-sys-0.2.9/
$ rm -rf .termbox
Now try building again.
That worked, thanks! It works great now.
Glad I could help.

Powered by DjangoBB