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 / How can i save data to a file and how can I load that data ?

Author
Message
Martin Donat
13
Years of Service
User Offline
Joined: 27th May 2011
Location: Czech Republic
Posted: 22nd Aug 2011 11:29
I want to make in my game save/load I need to save these floats:
character (image number of selected character on beginning)
money
level
experience
weapon (player can only have one weapon there will be 9 weapons)

How can I write these floats to a file ?
And how can I load it and tell the program what is what ?
Please help.

the leader of Mouseking studio

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Aug 2011 12:58 Edited at: 22nd Aug 2011 12:58
There are many threads that explain this, as found by using the Forum search:

http://www.google.com/search?q=save+data&btnG=Search&ie=UTF-8&oe=UTF-8&domains=http%3A%2F%2Fforum.thegamecreators.com&sitesearch=http%3A%2F%2Fforum.thegamecreators.com

Martin Donat
13
Years of Service
User Offline
Joined: 27th May 2011
Location: Czech Republic
Posted: 22nd Aug 2011 13:36
I know how to save and load, I donĀ“t know how to use it for storing/loading of things I need.

the leader of Mouseking studio

Quisco DaLuse
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: USA
Posted: 22nd Aug 2011 16:34
Quote: "How can I write these floats to a file ?
And how can I load it and tell the program what is what ?
"


Why you are using floats for those variables is beyond me, as float precision is not needed. It would be better to simply use integers. Anyway, it can be done by converting the floats to strings, and back, like this:


You will need to create a folder that has within it a folder named 'media'. The code will write the file in the media folder.

Login to post a reply

Server time is: 2024-11-22 17:07:45
Your offset time is: 2024-11-22 17:07:45