I'd like to give back to the community so I've decided to create study questions for each Handmade Hero episode, or at least the ones I've watched. I'm focusing on creating questions that will help people grasp both specific programming methods and more general design ideas. Here's some example questions:
Q: For files that save player data such as unlocks and progress, why shouldn’t you overwrite the current saved data file? What is a better alternative.
A: (explained at 1:00:40, further explained at 1:16:00): If the write fails for some reason, the data file could be corrupted and the player would lose all their saved data. A better strategy is to have a two file system, where the non-current file is overwritten. Another strategy is to have a temp file, write to the temp file, and then, if the write succeeds rename the temp file to overwrite the file.
Q. In the following line, what happens to the real32 value when casted to a DWORD:
DWORD SleepMS = (DWORD)(1000.0f * (TargetSecondsPerFrame -
SecondsElapsedForFrame));
A: Since DWORD is a unsigned 32 bit integer, it truncates the decimal value of the real32 floating point.
Q: Write a #define function that returns the amount of elements in an array
A: #define ArrayCount(Array) (sizeof(Array) / sizeof((Array)[0]))
I'd like any feedback on my general direction, whether it's a waste of time and or bad idea (considering I'm answering the questions), or any other feedback. Is there a good place to post the questions I've made so far?
Thanks a lot,
Stewart