A simple recreation of the classic Snake game employing dynamically loaded visualization libraries
./nibbler [-h] width height
-h
enable hard mode - snake accelerates
- wsad or UpDownLeftRight
- Esc - exit
- Space - pause
- 123 - select graphics module
- clang++
- ncurses
- SDL
- SDL_ttf
- SDL_image
make; make dylib
On MacOS a simple script has been included to install dependencies through brew. The install script also supports linux systems using apt
Install with : ./install.sh
Each graphics module is seperately compiled as a shared object and loaded dynamically during runtime. The game makes calls to the graphics library using the following class interface:
#ifndef IRENDER_HPP
# define IRENDER_HPP
class IRender {
public:
IRender(void) {};
virtual void init(void) = 0;
virtual char getInput(void) = 0;
virtual void destroy(void) = 0;
virtual void render(void) = 0;
virtual ~IRender(void) {};
};
#endif
A two dimensional char array representing the game state is made available to the library to draw the board.