Jethro's Braindump

Game API Design

tags
Software Engineering

Core Tenets from Handmade (Handmade, n.d.)

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. n.d. “How to Write Better (Game) Libraries | Handmade.Network Wiki.” https://handmade.network/wiki/7138-how%E2%82%9Co%5F%7Bw%7Drite%5F%7Bb%7Detter%5F%7Bg%7Dame%E2%82%97ibraries.

Links to this note