nSnake: A Clone of Old Classic Snake Game – Play in Linux Terminal

nSnake is a replica of the most popular old classic snake game that was developed using ncurses C library by Alexandre Dantas. The game can be played at command-line with textual interface in almost all GNU/Linux distributions.

The game is highly customizable and includes gameplay modes, keybindings, and even the GUI-like appearance of the application. There is only one difficulty, that you will have to compile it from source, unless you’re using Arch Linux system.

Features
  1. Clean GUI-like interface with nifty animations.
  2. Two games modes, with speed controls.
  3. Customizable gameplay, appearance and keybindings.

Install nSnake Old Classic Snake Game in Linux

A nSnake is available for almost all modern Linux distributions. In Ubuntu and other similar distributions it can be easily installed using apt-get command via PPA’s, but you will get version 1.5.

But, if you’re looking for a most recent version (i.e. 2.0.0), then you will need to compile it from source. So, here in this article we’re going to see how to compile the game in Ubuntu and Red Hat based systems.

Go to the official nSanke site and download the latest source tarball (i.e version 2.0.0) using below link.

  1. http://alexdantas.net/projects/nsnake/

Alternatively, we can also do a wget to download most recent source tarball.

# wget http://kaz.dl.sourceforge.net/project/nsnake/GNU-Linux/nsnake-2.0.0.tar.gz

Before compiling, make sure we’ve the ‘ncurses dev‘ installed on our system. To get it, simple use the following command.

$ sudo apt-get install libncurses5-dev		[On Ubuntu based systems]
$ sudo yum install ncurses ncurses-devel	[On Red Hat based systems]

Next, extract downloaded package and compile it as shown below.

$ tar -xvf nsnake-2.0.0.tar.gz
$ cd nsnake-2.0.0
$ make
$ sudo make install

By default, ‘make install‘ command installs the packages under following directories.

/usr/games/                       Executable file
~/.local/share/nsnake/            Settings and Score files

But you can also define a custom directory for the installation. For example, the following ‘make install‘ will install packages under ‘/home/tecmint‘ directory.

# make install DESTDIR=/home/tecmint

How do I Play nSnake game

The instructions are the same of any snake game. You manage a hungry snake and the mission is to eat as many fruits (means $) you can. Each eaten fruit boosts it’s size by two units. When snake collides with itself or walls the game ends.

There are currently, two modes: with borders and without borders. The mission is to earn points by eating as many fruits as you can to create biggest score.

You can start the game using the following command in the terminal.

# nsnake

Once, the game starts in the terminal, you will see a screen similar to below.

Install nSnake Game
Run nSnake
Play nSnake Game
Play nSnake Game
Random Walls nSnake
Random Walls nSnake
nSnake GameOver
Game Over

While starting game, you can On/Off borders as well as you can choose the speed of the game level. Snake can be controlled using arrow keys.

Game Controls

The game can be controlled and customizable using the following keybindings.

Arrow Keys          Moves the snake
q                   Quits the game at any time
p                   Pauses/Unpauses the game
h                   Show help during game
m		    Return to Main Menu

Uninstall Game

If you’ve installed the game via apt-get, you can simple use the apt-get command to remove it completely from the system.

$ sudo apt-get remove nsnake

If incase, you’ve compiled from source, you need to run the following command from the source installation directory to remove the files from the system.

# make uninstall

If you’ve specified a custom directory for installation, then define a path of installation directory along with `make` to uninstall properly.

# make uninstall DESTDIR=path-to-directory/

What’s your opinion about nSnake? Have you ever played it before? What other similar terminal games you play? Do share your views via our comment section.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

9 Comments

Leave a Reply
  1. Hi, I’m the creator of nSnake!

    Apparently this error is due to old versions of compilers.
    You have to update GCC to 4.8.X.

    I’m trying to work around it, because nSnake uses features
    from the latest version of C++ and some compilers don’t
    support it.

    Reply
    • Dear Alex,

      Thanks for updating our fellow users, will definetly compile it again using latest GCC as you suggested.

      Reply
  2. Great article!

    A small correction in the article though.

    In the how to play nSnake section, it should be nsnake not snake.

    Reply
  3. It doesn’t compile on Ubuntu 12.04.
    Make ends with “Error 1”:


    # Compiling src/Interface/Menu/MenuItemTextbox.cpp…
    src/Interface/Menu/MenuItemTextbox.cpp: In member function ‘virtual void MenuItemTextbox::handleInput()’:
    src/Interface/Menu/MenuItemTextbox.cpp:53:21: error: ‘std::string’ has no member named ‘pop_back’
    make: *** [src/Interface/Menu/MenuItemTextbox.o] Error 1
    $

    Reply
  4. i have error when i tryin to make command like :

    # Compiling src/Game/Score.cpp…
    # Compiling src/Game/Game.cpp…
    # Compiling src/Game/Board.cpp…
    # Compiling src/Game/FruitManager.cpp…
    # Compiling src/Game/Player.cpp…
    # Compiling src/Interface/LayoutMainMenu.cpp…
    # Compiling src/Interface/Ncurses.cpp…
    # Compiling src/Interface/Layout.cpp…
    # Compiling src/Interface/LayoutFirstTime.cpp…
    # Compiling src/Interface/Menu/MenuItemNumberbox.cpp…
    # Compiling src/Interface/Menu/MenuItemCheckbox.cpp…
    # Compiling src/Interface/Menu/MenuItem.cpp…
    # Compiling src/Interface/Menu/MenuItemTextbox.cpp…
    src/Interface/Menu/MenuItemTextbox.cpp: ‘virtual void MenuItemTextbox::handleInput()’ üye fonksiyonunda:
    src/Interface/Menu/MenuItemTextbox.cpp:53:21: hata: ‘std::string’ ‘pop_back’ isimli üyeye sahip değil
    make: *** [src/Interface/Menu/MenuItemTextbox.o] Hata 1

    Reply
  5. when run #make on centOS 5_32 bit getting following error:

    [root@wizn nsnake-2.0.0]# make
    # Compiling src/Misc/Utils.cpp…
    cc1plus: error: unrecognized command line option “-std=c++0x”
    make: *** [src/Misc/Utils.o] Error 1

    [root@wizn nsnake-2.0.0]# gcc -v
    Using built-in specs.
    Target: i386-redhat-linux
    Configured with: ../configure –prefix=/usr –mandir=/usr/share/man –infodir=/usr/share/info –enable-shared –enable-threads=posix –enable-checking=release –with-system-zlib –enable-__cxa_atexit –disable-libunwind-exceptions –enable-libgcj-multifile –enable-languages=c,c++,objc,obj-c++,java,fortran,ada –enable-java-awt=gtk –disable-dssi –disable-plugin –with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre –with-cpu=generic –host=i386-redhat-linux
    Thread model: posix
    gcc version 4.1.2 20080704 (Red Hat 4.1.2-54)

    Reply
  6. when run #make on centos 6_x64 bit getting following error:

    [root@t-server nsnake-2.0.0]# make
    # Compiling src/Misc/Utils.cpp…
    src/Misc/Utils.cpp: In function ‘void Utils::Random::seed()’:
    src/Misc/Utils.cpp:46: error: ‘nullptr’ was not declared in this scope
    src/Misc/Utils.cpp: In function ‘int Utils::Random::between(int, int)’:
    src/Misc/Utils.cpp:51: error: ‘uniform_int_distribution’ is not a member of ‘std’
    src/Misc/Utils.cpp:51: error: expected primary-expression before ‘int’
    src/Misc/Utils.cpp:51: error: expected ‘;’ before ‘int’
    src/Misc/Utils.cpp:52: error: no matching function for call to ‘distance(std::mt19937&)’
    src/Misc/Utils.cpp: At global scope:
    src/Misc/Utils.cpp:49: warning: unused parameter ‘min’
    src/Misc/Utils.cpp:49: warning: unused parameter ‘max’
    src/Misc/Utils.cpp: In function ‘float Utils::Random::fbetween(float, float)’:
    src/Misc/Utils.cpp:57: error: ‘uniform_real_distribution’ is not a member of ‘std’
    src/Misc/Utils.cpp:57: error: expected primary-expression before ‘float’
    src/Misc/Utils.cpp:57: error: expected ‘;’ before ‘float’
    src/Misc/Utils.cpp:58: error: no matching function for call to ‘distance(std::mt19937&)’
    src/Misc/Utils.cpp: At global scope:
    src/Misc/Utils.cpp:55: warning: unused parameter ‘min’
    src/Misc/Utils.cpp:55: warning: unused parameter ‘max’
    src/Misc/Utils.cpp: In function ‘bool Utils::Random::boolean()’:
    src/Misc/Utils.cpp:63: error: ‘uniform_int_distribution’ is not a member of ‘std’
    src/Misc/Utils.cpp:63: error: expected primary-expression before ‘int’
    src/Misc/Utils.cpp:63: error: expected ‘;’ before ‘int’
    src/Misc/Utils.cpp:65: error: no matching function for call to ‘distance(std::mt19937&)’
    src/Misc/Utils.cpp: In function ‘void Utils::File::mkdir_p(std::string)’:
    src/Misc/Utils.cpp:105: error: ‘struct std::string’ has no member named ‘back’
    src/Misc/Utils.cpp: In function ‘std::vector<std::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::basic_string<char, std::char_traits, std::allocator > > > Utils::File::ls(std::string)’:
    src/Misc/Utils.cpp:207: error: ‘struct std::string’ has no member named ‘back’
    src/Misc/Utils.cpp: In function ‘std::string Utils::File::getHome()’:
    src/Misc/Utils.cpp:233: error: ‘struct std::string’ has no member named ‘back’
    src/Misc/Utils.cpp: In function ‘std::string Utils::File::getUser()’:
    src/Misc/Utils.cpp:245: error: ‘struct std::string’ has no member named ‘pop_back’
    make: *** [src/Misc/Utils.o] Error 1

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.