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.

Newcomers DBPro Corner / SaveGame Fail please help

Author
Message
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 10th Aug 2010 14:19
I'm trying to create a save game file, all I'm trying to do is save the object position so next time you load it you can just load the save file and you'll be at the position you were when you saved it, I looked up a thread about it and wrote some code but it doesn't seem to work, can anyone help?



I'm betting it is something REALLY simple and once pointed out I shall probably facepalm myself

I can see from your smile, you're not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 10th Aug 2010 16:09
A few things worth mentioning.
1. x# and z# need to be global (or in an array) in order for their values to be used in a function like that.
2. You never see the saving / loading messages as creating an object will turn the backdrop on.
3. Why not write float values to the file instead of a long?

Edited code:


Hope this helps.

So many games to code.......so little time.
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 11th Aug 2010 00:32 Edited at: 11th Aug 2010 00:38
Outstanding! thank you. I didn't know you could write floats and such, this was my first attempt at such so i don;t know what you can and cannot write to a save file.

*edit*
If i have a variable like x# as a double float would i then have to write double float 1,x#? I'm assuming that it is possible right?

I can see from your smile, you're not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 11th Aug 2010 03:21
*double floats barely function in DBPro
also, you can declare variables like:

instead of

and it's generally considered better practice. also, I hate going shift+3 to get #... not that what any of I said is very relevant. Just throwing that out there


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 11th Aug 2010 16:56
Quote: "Outstanding! thank you. I didn't know you could write floats and such, this was my first attempt at such so i don;t know what you can and cannot write to a save file."


You are welcome. If you look in the HELP files it will show you what kinds of variables can be read / written to files.

Quote: "If i have a variable like x# as a double float would i then have to write double float 1,x#? I'm assuming that it is possible right?"


Actually, it is not possible to write a double float to a file (at least with DBP v7.4). Do you have an actual need for double float precision? Floats have always done a good job for me tracking object / camera positions.

So many games to code.......so little time.

Login to post a reply

Server time is: 2024-11-23 11:18:02
Your offset time is: 2024-11-23 11:18:02