Beginner C++ Game Programming Tutorial 21

From Chilipedia
Revision as of 15:22, 12 May 2017 by Chili (Talk | contribs) (Notes)

Jump to: navigation, search

2D arrays are awesome because they fuckin' let us organize or data and shit. Board games like chess, strategy games like Civilization, roguelikes, RTS games, X-Com... it's all grids baby. Also, time to learn how to circular depend our shit with forward declaration (you should still avoid circ. dep. when possible tho).

Topics Covered

  • Mapping from a logical 2D array to a 1D array
  • Using forward declaration to enable circular dependency by breaking a circular #include chain

Notes

Here's an article I found that I like. I like it because it shits in the mouth of multidimensional arrays, which I am no fan of. I maybe wouldn't agree with 100% of what this dude is saying, but it's mostly valid points: fuck MD arrays forever.

Also see this discussion here: Chili talks about [][] arrays.

Video Timestamp Index

Tutorial 21

Source Code Download

Snek Repository

Homework

The goal for this video's homework is to modify Snek so that the field can contain 3 things (besides the Snek): goals, obstacles, and poison. Hitting an obstacle ends the game. Hitting a goal will grow the Snek and spawn another goal and an obstacle. Hitting a poison will speed the Snek up.

Other good modifications include: not speeding up the Snek over time or when a goal is eaten (the poison is enough for that) and adding a speedup key that can speed the Snek up to a certain speed (but never slower than its current normal speed).

The solution to this homework is coming soon.

See also