Skip to content

Snake! In Terminal! With ncurses! Ugh... (>_<)

License

Notifications You must be signed in to change notification settings

baatochan/TerminalSnake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TerminalSnake

Snake! In Terminal! With ncurses! Ugh... (>_<)

Author: Bartosz Rodziewicz

About

This game is simple implementation of snake idea. It's written in C++ with ncurses as a TUI. The code that provide ncurses support is based on jvns/snake repo that is under MIT license (Copyright (c) 2013 Julia Evans).

Dependencies

  • Release
    • ncurses
  • Debug
    • Threads
    • Google Test (included as a submodule)

Run

To run a game create a new folder in project root dir, run cmake and make, eg:

mkdir cmake-build
cd cmake-build
cmake ..
make run

The game will automatically close after you loose.

CMake settings

The app provides few targets depending on cmake build type. To set build type you need to pass -DCMAKE_BUILD_TYPE parameter when running cmake, eg: cmake -DCMAKE_BUILD_TYPE=Debug ...

When parameter is not set the Release build type is set automatically.

The build types naturally differs with the compiler flags used (more about that in cmake docs).

Release

This build type contains three main targets:

  • TerminalSnake - game itself
  • run - compile TerminalSnake target and run it
  • install - more about that in Install paragraph.

This build type require ncurses library installed in your system (on Ubuntu can be installed using sudo apt-get install libncurses5-dev) and should not require googletest submodule.

Debug

This build type contains 3 more targets:

  • UnitTests - gtest unit tests
  • runUnitTests - compile UnitTests and run it
  • test - compile UnitTests and run it using ctest (you can do it using ctest command as well)

It requires googletest submodule, before running cmake make sure you have this submodule initialized and updated (eg. git submodule update --init --recursive --jobs 8).

More targets (auto-generated by cmake) can be found with command make help.

git submodule update --init --recursive --jobs 8
mkdir cmake-build
cd cmake-build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make runUnitTests
ctest
make run

MinSizeRel

Same as Release (difference in compiler flags tho).

RelWithDebInfo

Same as Debug (difference in compiler flags tho).

Installation

This game contains install target which lets you install the game.

It installs the game to the default (for cmake) directory. To specify custom directory you need to use -DCMAKE_INSTALL_PREFIX parameter.

Installation of googletest is turned off. install target can be turned off completely using -DINSTALL_TERMINALSNAKE=OFF parameter.

mkdir cmake-build
cd cmake-build
cmake -DINSTALL_TERMINALSNAKE=OFF ..
make install
#	make: *** No rule to make target 'install'.  Stop.