I created a snake game using C++, without the use of any graphics library.
To see how this games looks and work
https://www.youtube.com/watch?v=HlmdeXelTsM
I used following libraries-
- conio.h
- time.h
- synchapi.h
- windows.h
The code snake.cpp is final game consists of all features, which is too efficient and its speed is great (you can't play custom: 0), it doesn't have screen flickering issues, the size of board can be increased without compromising the effciency of game.
- Various difficulty mode- Easy, Medium (Default), Hard, Custom (set the time in milliseconds)
- P can pause the game
- S can open the settings of game in exit screen or in welcome screen.
- C can end the game
- esc is used to exit the game at exit screen
- It has many settings to modify the game.
- Can pass though walls (modify in settings) (Default- No)
- Can go reverse (modify in settings) (Default- No)
- Can't die by touching its own body (modify in settings) (Default- No)
- Change the dimensions of board (modify in settings) (Default- 27 118)
- Two modes- Board can be made up of colours or of characters (modify in settings) (Default- Colour)
The other code snake_naive_approach.cpp is the naive approach to this game, which I formed initially, it overwrites the whole screen and then writes it, then clears then writes it, so its not so efficient, slow but has a smaller code (almost half).