Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
bushsucks
22
Years of Service
User Offline
Joined: 8th Mar 2003
Location: United States
Posted: 28th Apr 2003 03:17
I'm trying to make a save game feature, so I'm going to save the values of some variables into a file. What is the best way to do this? In the swarm game that came with DarkBasic, they load the high score, by loading an array from the file, but that was only for 1 piece of data. Is there a better way for loading and saving several pieces of data, if not, how exactly do you do the 1st method. Thanks.
don't re-elect bush
AsriCE
22
Years of Service
User Offline
Joined: 10th Jan 2003
Location: Brunei
Posted: 28th Apr 2003 14:07
You could save all the necessary values into a file.

If File Open(32)=1 Then Close File 32
If File Exist("Temp.dat")=1 Then Delete File "Temp.dat"
Open To Write 32, "Temp.dat"
Write Byte 32, Enemies : `Use "Byte" For Writing Single Variable.
Write String 32, Text$ : `Use "String For Writing Strings.
Close File 32

Asri CE Crew

Anak Brunei!
Leade
22
Years of Service
User Offline
Joined: 8th Nov 2002
Location: United Kingdom
Posted: 28th Apr 2003 18:15
Even better if you have Db 1.13 then all you do is add the variables to a memblock at certain positions for example:
add a string as position 1
a number a position 10
and a long at position 20

then save the memblock to a file.
when the data is needed load the memblock from the file and get the data:
get the string from position 1
the number from position 10
and the long from position 20

creating a save and load sub that does it automatically will easier
then add them to the variables.
Create the save command first and save a few bits of data, then try the load command and if it returns the correct values then you have a winner.
Rembember to load the data from the correct positions or you may crash your game.

Leade.
bushsucks
22
Years of Service
User Offline
Joined: 8th Mar 2003
Location: United States
Posted: 29th Apr 2003 03:22
thanks alot guys, this will really help me

don't re-elect bush

Login to post a reply

Server time is: 2025-05-19 10:28:38
Your offset time is: 2025-05-19 10:28:38