Waaaay back in the dark ages of junior high school, I lost many hours to this classic 2D platformer from John Romero. My tribute to these good times is this tutorial for beginner programmers.
The ten-part video series recreates the game using C and SDL with a few interesting limitations: I’ve kept a static design using basic features of the C language. No function pointers, memory allocators, or custom data structures with opaque operations. We fit around 1,000 lines in to a single file. Total run time of the videos is just under two hours.
The goal is a reasonably complete (and winnable) version of Dangerous Dave with the minimum amount of design. I've skipped many best-practices for scalability and maintainable design in order to keep this accssible for beginners. The code comes in at around 1000 lines in which we define 30 procedures. Below, we'll review the namespace of the project, which includes C standard library functions, SDL functions, and game state variables. I'll break down the game loop as it developed over the course of the project.
SDL is a development library that connects program logic to output devices. We'll use 19 functions (of the 536 SDL2 defines) to bring Dangerous Dave to life.