Requesting code review - Snake Game

Hello all. I am a C++ beginner and to practice I made a classic Snake clone using a media library called SFML.

I am requesting you all to go through the code and guide me what could be better and how.
Also, please play the game and see if its working alright.

Snake Game - https://drive.google.com/file/d/0B_XEonRcHGvwNnhXTVFHMEJGSEE/view?usp=sharing
Snake Code - https://github.com/gitPriyesh/Snake



I found practicing through making small games to be really a good learning experience.
It looks like you have a pretty good start. Nothing magically stellar, but nothing truly horrible at just a glance.

One suggestion: break the main loop up. You are doing too much stuff in one loop.

Instead, there should be multiple loops, depending on the game's current state.

For your example, you should have a loop that manages the main menu (starting a new, game, quitting, etc). Then call a function that implements the game-play loop. When game play stops, simply return to the main function/loop.

Hope this helps.
Thanks, Duthomhas, for taking a look at the code. It means a lot.

One suggestion: break the main loop up. You are doing too much stuff in one loop.

OK, I'll keep this in mind in my future projects or may be just re frame this code.


you should have a loop that manages the main menu (starting a new, game, quitting, etc)

Does this mean, even rendering of those different parts of the game should have been handled separately?

Any and all feedback helps. Thanks again. :)
It's a great game, you should try making Conway's Game of Life and showing cells in 1 and 0's
Thanks, Masecla33 for checking it out.

you should try making Conway's Game of Life and showing cells in 1 and 0's


It could really be an interesting project, but at this moment of time it's a little complex for me. I'll definitely give it a try in future. It would be really interesting to see 1 and 0 as live and dead cells.
It's actually not that hard, if you could make that snake game, you surely can make a game of life ;D
@Masecla33

I am not worried about logic or algorithm I need to use but about interactive UI. That's a hard aspect of it, not the game itself.
Topic archived. No new replies allowed.