You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Constantin Fürst 4d63363f34 add screen refresh 6 months ago
components Merge branch 'lesson02' into lesson03 6 months ago
input-output implement lesson01 6 months ago
.gitignore restructure and use cmake 6 months ago
CMakeLists.txt restructure and use cmake 6 months ago
LESSONS.md implement lesson03 6 months ago
LICENSE write readme and update license 6 months ago
README.md write readme and update license 6 months ago
build-and-run.sh write readme and update license 6 months ago
main.cpp add screen refresh 6 months ago

README.md

Snake Game for learning C++

Abstract

A simple snake game, with terminal GUI implemented using ncurses library. Taken from Vissa Moutafis LINK and heavily modified.

Required Knowledge:

This project is meant for those with a little programming experience in any other language or a general overview of programming concepts. If you can tell the terms "Object" and "Class" apart, know what a function is, know basic git and have used a command line before, then this project will teach you through exploring and solving challenges by yourself how to program C++. If you don't know these terms but can take a big challenge, then this is still a good starting point. Just try to figure out what is going on and you will learn a lot.

Resources:

  • cppreference for information on all elements of the language, quite detailed and might be overwhelming for beginners
  • Cherno C++ Playlist for an overview of all components of the language in a very beginner-friendly format
  • stackoverflow when you have a problem, most of the time, someone else has encountered it too, and you will find help and examples when web-searching and clicking on links to this site
  • Tetris for Windows code-along tetris video for the windows command line with good and beginner-friendly explanations

Controls:

  • Up-Arrow to go up.
  • Down-Arrow to go down.
  • Left-Arrow to go left.
  • Right-Arrow to go right.
  • q to exit game.

Prerequisities

You need to install the following packages:

  • ncurses : Terminal User Interface Library "ncurses"
  • cmake and make : Build Tools
  • gcc or clang : C/C++ Compiler

If you use MacOS then you must install homebrew for access to the packages. On Windows you must install and set up WSL to get a Linux command line. Open up a terminal and type the folllowing commands:

# Most Linux distributions and WSL under Windows
~$ sudo apt-get install gcc make cmake libncurses5-dev libncursesw5-dev
# On MacOS
~$ brew install clang make cmake ncurses
# Or for FreeBSD
~$ sudo apt-get install clang make cmake ncurses

Now you are ready to use the repo.


Downloading, Instalation and Running the Program

Now we will install and run the program, but first let's download the repo:

~$ git clone https://git.constantin-fuerst.com/constantin/snake
# cd in the directory
~$ cd snake
# select the correct branch for learning
~$ git checkout lessons
# or cheat and look at the solution / see what you will achieve with
~$ git checkout master
# run the helper script to build and execute
~$ bash build-and-run.sh

and begin your journey through C++!


How to learn

  • Perform Setup like above
  • Run the game on master branch
  • Explore the code
    • set up a development environment for c++ on your computer - see the Cherno Playlist first few videos for help
    • try to figure out what's going on in the components and game subfolders
    • find out what a preprocessor, compiler and linker do - see the Cherno Playlist first few videos for help
    • check out the CMakeLists.txt and build-and-run.sh files and the created build folder and try to understand how they lead to the application going from code to executable
  • Change to branch lessons
  • Move to LESSONS.md for further tasks