33 thoughts on “Beginner C++ Game Programming DirectX [Snake Game] Tutorial 14a

  1. Since the Location struct didn't have much inside of it, would it have been okay to pass it by value instead of by reference?

  2. why do arrays need to specify the size at compile time, not runtime? the space is allocated at runtime (because i need to run the program to do anything) ?
    int size = std::rand() % 10;
    int arr[size]; // fail?
    arr[size – 1] = 9;


  3. so i cannot make arrays/collections with a size calculated in runtime? wtf? do i really need to make a list class with items and so on by myself? such a basic thing?

  4. I know this video is 3 years old and stuff but instead of making the segments "follow" the head you can just pop the tail and move it to "delta location"

  5. Well I started watching a year ago…but discontinued cuz of time mangement issues….now i return
    but my question is…
    We are all doing this on framework…so actually we dont yet know how to make window or do the graphics…or do some task…we are using frameworks
    whats the point of framework…are the intermediate and advanced series also dependant on framework….do the intermediate and advance series teach us doing things like graphics and windows without framework?

  6. Do I have to do this with a static sized array? Is there a more dynamic approach where I can in pseudo code write

    for instances in game where it will loop over every object of type X currently initialized

  7. I managed to program 90% of it on my own, but I done it a lot sloppier then you haha. Functionality is the same, but the code is a bit messier.

  8. After a year + few months… I've finally finished the snake game. Holy shit. I was so frustrated and would stop periodically and come back and just hate this program so much.

    I told myself I could complete the game without watching 14b, and I did! I did it! It took over a year, but I did it! I am very happy and had to post this somewhere. 🙂

  9. Chili, can you explain the statement gfx(gfx) used to initialize the graphics object (timestamp 9:58). I'm slightly puzzled by this. Does this call the constructor of the gfx class (that seems to use "= delete" language)? Or is it essentially a syntax for an assign (gfx=gfx)?

  10. Wow. Great video again. It is just awesome to learn the logic & ridiculously structured approach to your coding.

    Before I watched, I tried to implement the game myself and took a completely different approach:

    >Basically just one Board class that contains one array (size: boardwidh * boardheight). Array index counts from top left cell (your "segment") to bottom right cell.
    >An int member variable keeping track of the index of the snakehead, and an int member variable length keeps track of snakelength
    >Based on kbd input, snakehead is moved by putting the value snakelength in the adjacent cell (using some index logic)
    >Then when you update the board, you reduce all values in the array by 1, and then draw the whole board (member function of Board) by running through the array: draw the cell if array[i] value > 0. This way, the tail "automatically disappears" once it has counted down to 0..

    Although I found my approach elegant, yours is of course much better. It's just such a rewarding way to learn. THANKS CHILI!!

  11. This is a bit challenging. Because it took me while to think the call relation of the snake and snake segments. I found out snake class is just keeping calling the snake segments, looping the snake segments and putting small expressions together in bigger functions.

  12. 14:48
    Location loc = { x, y };
    how does that { x, y } link to the x and y ints in the Location.h file, or is it not linked at all?

  13. I wish you followed a more rigid naming standard for member variables in these early tutorials like int m_posX or something. From experience, this plants some bad habbits in newbie programmers.

Leave a Reply

Your email address will not be published. Required fields are marked *