Browse Source

write readme and update license

master
Constantin Fürst 6 months ago
parent
commit
5bfbbf21fa
  1. 3
      LICENSE
  2. 92
      README.md
  3. 1
      build-and-run.sh

3
LICENSE

@ -1,6 +1,7 @@
MIT License MIT License
Copyright (c) 2020 Vissarion Moutafis
Copyright (c) 2020-2024 Vissarion Moutafis
Copyright (c) 2024 Constantin Fürst
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

92
README.md

@ -1,8 +1,20 @@
# Snake Game in C++
# Snake Game for learning C++
## Abstract ## Abstract
A simple snake game, with terminal GUI implemented using ncurses library. A simple snake game, with terminal GUI implemented using ncurses library.
Taken from Vissa Moutafis [LINK](https://github.com/VissaMoutafis/Snake-Game-in-Cpp) 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](https://en.cppreference.com/w/)__ for information on all elements of the language, quite detailed and might be overwhelming for beginners
- __[Cherno C++ Playlist](https://www.youtube.com/watch?v=18c3MTX0PK0&list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb)__ 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](https://youtu.be/8OK8_tHeCIA)__ code-along tetris video for the windows command line with good and beginner-friendly explanations
#### Controls: #### Controls:
@ -12,36 +24,27 @@ A simple snake game, with terminal GUI implemented using ncurses library.
- __Right-Arrow__ to go right. - __Right-Arrow__ to go right.
- __q__ to exit game. - __q__ to exit game.
### TODO:
- [x] Increase speed of the snake when it devours a snack.
- [x] Add a scoreboard.
- [ ] Fix the window-resize factor, since it gets all messy when you minimize/maximize the terminal window.
- [x] Create a 'Game' class and provide interface through that function so that the user don't have to mess with the graphics snake and controller classes.
- [x] Implement the Game::printGameStatistics function to print the score and games played of each player.
--- ---
## Prerequisities ## Prerequisities
You need to install the following packages: You need to install the following packages:
- __libncurses5-dev__ : Developer’s libraries for ncurses,
- __libncursesw5-dev__ : Developer’s libraries for ncursesw,
- __gcc__ : C\C++ compiler,
- __make__ : instalation tool.
- __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: Open up a terminal and type the folllowing commands:
```shell ```shell
#make sure everything is updated
~$ sudo apt update && sudo apt upgrade
#Now to install compiler and instalation tool
~$ sudo apt-get install gcc make
# 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
#And the actuall library (ncurses)
~$ sudo apt-get install libncurses5-dev libncursesw5-dev
``` ```
Now you are ready to use the repo. Now you are ready to use the repo.
@ -52,38 +55,29 @@ Now you are ready to use the repo.
Now we will install and run the program, but first let's download the repo: Now we will install and run the program, but first let's download the repo:
```shell ```shell
~$ git clone https://github.com/VissaMoutafis/Snake_Game_in_Cpp
~$ git clone https://git.constantin-fuerst.com/constantin/snake
# cd in the directory # cd in the directory
~$ cd Snake_Game_in_Cpp
#run the 'make run' to install and play
~$ make run
~$ 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 enjoy playing!
__Note__: You might want to delete the objective files and keep only the src part (__clean up__). In that case:
```shell
~$ make clean
```
and you are set.
and begin your journey through C++!
--- ---
## Contributors
[VissaM](https://github.com/VissaMoutafis)
Special thanks to [plato(otalpster)](https://github.com/otalpster) for fixing a bug that i would never notice! (Thnx man)
---
## Licence: MIT
Check the file LICENCE or click the following [link](https://github.com/VissaMoutafis/Snake_Game_in_Cpp/blob/master/LICENSE).
## Appendix
If you are interested to know more about terminal gui apps and __especially ncurses library__, check [this](http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/index.html) out!
Another ncurses guide (maybe more begginer friendly) is [this](http://www.cs.ukzn.ac.za/~hughm/os/notes/ncurses.html) one.
### Enjoy!
## 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

1
build-and-run.sh

@ -1,3 +1,4 @@
#!/bin/bash
mkdir build mkdir build
cd build cd build
cmake .. cmake ..

Loading…
Cancel
Save