20

GitHub - leimao/Console_Snake: Snake Game in Console Implemented Using C++

 4 years ago
source link: https://github.com/leimao/Console_Snake?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Console Snake

Lei Mao

Introduction

The Console Snake game with background music was implemented using C++ and the libraries libncurses and libcplayer. libncurses (new curses) is a programming library providing an application programming interface (API) that allows the programmer to write text-based user interfaces in a terminal-independent manner. libcplayer(console player) is a C++ library for playing background audios asynchronously in C++ programs.

Dependencies

Files

.
├── audios
│   └── bgm.wav
├── CMakeLists.txt
├── demo
│   ├── console_snake_demo.gif
│   ├── console_snake_demo.mp4
│   └── mp42gif.sh
├── LICENSE.md
├── modules
│   └── Console_Player
├── README.md
└── src
    ├── CMakeLists.txt
    ├── game.cpp
    ├── game.h
    ├── main.cpp
    ├── snake.cpp
    └── snake.h

Installation

Installation of CMake

Check out the installation guide from Kitware.

Installation of Dependencies

$ sudo apt-get install libncurses-dev libsndfile-dev libasound2-dev

Installation of the Game

Because the installation requires to use git submodule, please git clone instead of download the repository.

$ git clone https://github.com/leimao/Console_Snake.git
$ cd Console_Snake
$ git submodule update --init --recursive
$ mkdir -p build
$ cd build
$ cmake ..
$ make
$ make install

Usages

Game Rules

Control the snake to eat food as much as possible. You get one point for every food your snake eat. The level of difficulty would increase every 5 points you get.

Playing the Game Using Default BGM

$ cd bin/
$ ./main

Playing the Game Using Custom BGM

The user is also allowed to use custom BGMs.

$ cd bin/
$ ./main [bgm_sound_file]

Currently the game only supports wav, ogg, and flac audio formats.

For full demo with sound, please click the demo image and watch the YouTube video.

Feedbacks

If you have encountered any bug, or have any suggestions for improvements, please open an issue ticket in the repository.

References

To-Do List

  • Add leader board
  • Add background music
  • Allow user to save player name to the leader board

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK