Examples please if poss
Blitz3D Forums/Blitz3D Programming/Examples please if poss
| ||
Okay I have a lot of single level games and I am now losing momentum with my coding. What I want is to be able to load another level after one is complete...so I need to clear one level completely and load another. Also what about saving games progression.....AHHHHHH What about a RE style game where each "room" is loaded and you can go back and forth between rooms. Am I expecting too much. Any examples or pointers would be appreciated. |
| ||
BTW I did ask a similar question a while back but I am still struggling. Thats why any good examples would be appreciated. I am really looking at a single static model per level, a few moveable objets and maybe 3 inventory items max. I assume I need to dynamically read and write to a file which will keep the status of each object. Then use this as the save and load as well as ingame inventory system. But how ???? |
| ||
Level saves are pretty straightforward. Assuming you have enverything positioned per levle in you game, you can save it to file with a functionFunction save_to_file(indx%) ; Outputs object data ; opens files for indx% level f$="level"+indx%+".dat" file=WriteFile(f$) ; output all 100 actors For Every Object ; Output details WriteInt (file,Object type) WriteFloat (file,Object's X position) WriteFloat (file,Object's Y position) WriteFloat (file,Object's Z position) WriteFloat (file,Object's X rotation) WriteFloat (file,Object's Y rotation) WriteFloat (file,Object's Z rotation) Write Any other Pertinent Details such as Camera position, rotation CloseFile(file) End Function Then you create a read function that reads in the data in the same order you saved it... Function load_from_file(indx%) ;loads data into the setup arrays ;reads files for level n% f$="actors"+indx+".dat" file=ReadFile(f$) ; input all 100 objects For Every Object ; Input details n=ReadInt (file) Object Type = n n=ReadFloat (file) Object X position = n n=ReadFloat (file) Object Y position = n n=ReadFloat (file) Object Z position = n ...etc... ...etc CloseFile(file) End Function In your game when you want to swtich levels, delete all the old objects, load in the details of the new objects and create tham as you did to begin with. In my case I have an array to store object details and object creation functions. I load the data from file into the array, and then go through the array creating objects. When I close a level I go through the array and delete all the objects, load the next lot of data, and create the new scene. If you want dynamically altered scenes you can do the same, just keeping a copy of the original level data in one place and a copy with any modifications in the player's save directory. |
| ||
For Every Object Uh? Is that Bmax code, or something? ...or pseudo code? |
| ||
Pseudo code. |