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.

Dark GDK / Need help with reading and writing files (code included)

Author
Message
Vlad
19
Years of Service
User Offline
Joined: 5th Oct 2005
Location:
Posted: 21st Aug 2006 12:19
Hi,

I'm trying to write the levels of my game to files. Here's the classes code:

classes.h



classes.cpp



Now a little rundown of what's happening. I've used the level::initLevel to create the files. You can see I wrote ints and floats. The resulting file is a long line of nothing.

I think that, since all values were 0 when I initialized the files, that the line written on the file is a string of NULL.

When I read the file to edit or play a level, using level::loadLevel, all my variables have, instead of 0, initializing values, for instance, level.lastPiece is 643124 instead of 0. That happens to both ints and floats.

Any ideas of what I'm doing wrong?

Thank you in advance.

V

The only lazy people that can complete games are genius. You don't look like a genius, so you better stop being lazy.
Support your local Riker 9 Chapter.

Attachments

Login to view attachments
Ashy
19
Years of Service
User Offline
Joined: 1st Nov 2005
Location:
Posted: 21st Aug 2006 17:59
From what I remeber... dbwritefloat/file/byte .etc writes the info to the text file at byte level.. not ascii.. so when you try to read it back you get jibberish.. write/readstring works ok.. but anything writing an int/float .etc turns out crap. Not sure if i'm right or not.. but i remember someone saying something about that in the DBP forum long ago.. its the reason i couldn't use the standard write/read commands to store my program settings.. i had to go and find a kernel32 ini file writing function to work. Having this same problem now when i'm trying to learn c++.. i got the dbp one working (awesome) but now i don't know what i'm doin with the sdk lol. Try using fstream and << .etc to make your files...or the number results anyway.

I'm sure one of the big guns like ian m or philbert will elaborate on it.
Vlad
19
Years of Service
User Offline
Joined: 5th Oct 2005
Location:
Posted: 21st Aug 2006 18:16
I'm trying to use fopen fputs, etc. But still the variables on my objects aren't being handled correctly. I still get a load of jibberish. So I'm guessing it's not only the SDK's fault it's also my own, but I have no clue on how to fix it.

The only lazy people that can complete games are genius. You don't look like a genius, so you better stop being lazy.
Support your local Riker 9 Chapter.
Wilvis
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location:
Posted: 22nd Aug 2006 06:04
here is what i use for fil functions. then been working great so far

Filefunction.h


Filefunction.cpp



that should help you out a bit.

Login to post a reply

Server time is: 2024-11-19 07:20:04
Your offset time is: 2024-11-19 07:20:04