Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Saving a game... problems and more problems :(
I have recently made a game in OpenGL. I want to program a Quicksave and Quickload feature. The problem is this: My game consists of classes and the main class contains a cyclic linked list of the world environment and enemies. I have no clue on how to write this info to a data file.
CEntity *worldObjs; // cyclic linked list
I attach nodes to the base CEntity class through my linked list. Unfortunately the command:
fwrite(world, sizeof(CWorld),1, fp);
does not work when I try to load it:
fread(world, sizeof(CWorld),1, fp);
Must I loop through each object of the linked list and save each one individally? This is tedious and I think there must be a better way. Besides, each object has its own pointers etc. which means I may have to loop through each pointer of each object in the list; I do NOT want to resort to this. Plz help?