C++ Tutorial 18 – Simple Snake Game (Part 1)


C++ Tutorial 18 – Simple Snake Game (Part 1)

Welcome to my simple game tutorial on C++. In this tutorial i will going to show you how to make a fun snake game.

We will structure the code of the game and do some basic drawing in the console.

Source code:
Finished game:
Download link for visual studio 2012 express:

Great C++ books that I recommend for beginners:
C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart (3rd Edition)

C++ Primer Plus (6th Edition) (Developer’s Library)

Programming: Principles and Practice Using C++ (2nd Edition)

If you have any questions I’ll be glad to answer, please leave a comment on the video.

Thanks for watching and please subscribe.

Nguồn: https://alimentproteine.com/

Xem thêm bài viết khác: https://alimentproteine.com/cong-nghe/


  1. I put the code in C++ star codin but when visual analize the code.. the code #include always comes as an error…. plus when i wanna start checkin the game if is goin good i just get 1 error after an other… my visual just doesnt go well !!! Always when i wanna start clang error comes up ?! Help

  2. Im use to code in game maker studio, I found your tutorial very nice to a pure c++ introduction. Great Work!

  3. To those of you on unix, I provide this snake game ported to ncurses!
    (note, if you're compiling with gcc make sure you use "-l ncurses" or you'll get a linker error)

  4. Another way to write the inner loop for the two side walls is
    if(j == 0 || j == width – 1)


    else cout<<" ";

  5. I am using Clion in Linux and system("clear") doesn't work in terminal(IDE, Linux Terminal).

    I am desperate, I can't figure it out for days.
    Any idea?

  6. for Draw() function, i think this might be better:-

    system("cls"); // we must #include <iomanip> (header file)
    cout << setfill('#') << setw(width) << "" << setfill(' ') << endl;
    for (int i {0}; i<height; i++)
    cout << setw(width/2) << left << "#"<< setw(width/2) << right << "#" << endl;
    cout << setfill('#') << setw(width) << "" << setfill(' ') << endl;

  7. prob dumb question but I cant build past the firs function put in and the log just says setup was nont declared in this scope any suggestions (side note* im using code::blocks)

  8. Jst a correction.
    At lime 33 tht cout " " happens regardless of any condition so we have extra 2 blocks… so putting tht under a if else condition will fetch u an exact 20*20


Please enter your comment!
Please enter your name here