How should I handle missing resources?

Posted by concept3d on Game Development See other posts from Game Development or by concept3d
Published on 2013-11-11T07:04:43Z Indexed on 2013/11/11 22:17 UTC
Read the original article Hit count: 243

Your game expects a certain asset to be loaded, but it isn't found. How should the situation be handled? For example:

Texture* grassTexture = LoadTexture("Grass.png"); // returns NULL; texture not found
Mesh* car             = LoadMesh("Car.obj");      // returns NULL; 3D mesh not found

It might have been accidentally deleted by the user, corrupted or misspelled while in development.

Some potential responses:

  • Assertions (ideally only during development)
  • Exit the game gracefully
  • Throw an exception and try to handle it.

Which way is best?

© Game Development or respective owner

Related posts about resources

Related posts about resource-management