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.

DarkBASIC Professional Discussion / Save and load code is not working and frustrating me

Author
Message
Daniel wright 2311
User Banned
Posted: 19th Apr 2011 02:43 Edited at: 19th Apr 2011 02:53
I know, third post today right? lol, But here is the problem, After learning the last 2 things I needed there was nothing else to do for this game but add new levals but before this i figured add some save and load code now before I add more stuff to it.

But. it does not work like it used to and Im confused, please help.
this code used to work fine, I belive its the saving part of the code messing up, but when i load everything loads funny and out of place.

edit: this is how my game loads with this code
edit:2 and this is how I am testing the code in a loop







my signature keeps being erased by a mod So this is my new signature.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Apr 2011 04:25
You need your read and writes inside the for loops.

Warning! May contain Nuts!
Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 19th Apr 2011 17:17 Edited at: 19th Apr 2011 17:20
Yes.

You seem to understand that you need to record the positions and angles of your objects to create a savegame file, and that you load these values back in and assign these properties to your objects when you load the game.

However, your logic is out. As WLGfx mentioned, you need to move your read and write commands inside the FOR...NEXT loops, otherwise you're only going to read and write the position of one single object.

Try this code:



All I've done is move two blocks of code around. The first block of code is a set of WRITE commands in the SaveGame() function and the second block is a set of READ commands in the LoadGame() function. I've put REM statements in the code above to show you what I've done.

Other than that, I've added proper indentation to the code. Try to get used to this, as it makes reading your code much easier for people who are helping you debug.

Daniel wright 2311
User Banned
Posted: 19th Apr 2011 18:40
Ok, I know see the error, its funny how you need to keep it in the next for loop but I ok with this and understand why but in the end if it saves thats all that matters, it works now, thanks guys.And I will start to add proper indentation to my code.

my signature keeps being erased by a mod So this is my new signature.

Login to post a reply

Server time is: 2026-07-18 14:26:31
Your offset time is: 2026-07-18 14:26:31