Jethro's Braindump

Game API Design

tags
§software_engineering

Core Tenets from Handmade (Handmade, 2019)

Maximize portability

  • Write in C99 if possible
  • Try to avoid:
    • compiler extensions
  • Do:
    • Use the C standard library
    • Undef macros that should not be exposed to the end user
    • Prefix names to avoid collisions
    • Write the interface in C

Be easy to build

  • Don’t use a custom build system
  • Make build system optional
  • Allow people to compile from source
  • Minimize dependencies
  • don’t allocate memory or handle resources for the user
  • be const correct
  • always ask for the size of buffers

Be easy to integrate

  • Consider error codes or result structs that must be handled at runtime
  • Keep error code/reason in struct
ParsePNGFileResult result = ParsePNGFile(png_file_data);
if (result.error) { /* handle error */ }

Bibliography

Handmade, (2019). How to write better (game) libraries | handmade.network wiki. Retrieved from https://handmade.network/wiki/7138-how_to_write_better_game_libraries. Online; accessed 12 December 2019.

Icon by Laymik from The Noun Project. Website built with ♥ with Org-mode, Hugo, and Netlify.