Qbasicnews.com

Full Version: saving
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey all,
I have made my game, good to play until you try to save it n figure out that you can't. Can someone give me code to save the current settings/game/file etc or at least point me in the right direction

Thanks very much guys
Dave

Anonymous

what it really comes down to is a couple of things...
1. what type of game it is
2. your personal variables
3. your knowledge of file manipulation

first off, you have to figure out what exactly it is youre saving. for instance if its an rpg, you would want to save things like HP, MP, level, stage in quest, spells known... etcetc you basically just have to pinpoint what it exactly is that is different about the game because you saved it as opposed to starting a new game. is this making sense? :o anyways once you get to that point you have a couple of options, depending on ur knowledge of files. hopefully you understand the 'open' statement. im not going to go into it here, but basically you could either take all your variables and combine them into a big long string and write that to a file. its also easier in that circumstance if you write in 'seperators' such as * or just something that code parsing your string would understand as 'get the next variable now' the other option is to write in the entries one at a time, making multiple lines in the destination file. on the other hand if you have a good understanding of binary files, you can write the values directly as binary values (chr$(number) for number and text for text) i hope this helped somewhat.. phew its long... just remember the most important part is figuring out exactly what to save. saving its easy. if you REALLY want you could send me variables and such and i could help you with specific code. email me
Yeah, as my fella said, it depends on the data you wanna save. For example,

Code:
f%=FREEFILE
OPEN "savegame.sav" FOR BINARY AS #f%
PUT #f%,,gold%
PUT #f%,,map%
PUT #f%,,xpos%
PUT #f%,,ypos%
...
CLOSE #f%