Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Basic General > Re: Freebasic, ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 654 of 684
Post > Topic >>

Re: Freebasic, newb question about file operations.

by "Auric__" <not.my.real@[EMAIL PROTECTED] > Feb 26, 2008 at 05:17 PM

On Tue, 26 Feb 2008 15:22:37 GMT, Angbandit wrote:

> Hi, I've been working on a game for the last decade off and on and
> I've come to the point now that I need to learn how to create and
> read files.
>
> For instance, my game creates a player character for an RPG and I
> need to be able to save the data to a file with the same name as
> the player such as "Conan.dat".  I need to be able to then load the
> data from that file and play it in the game, like the old Might and
> Magic and Wizardry games used to do.  I've gotten as far as open as
> binary and write and such, but I guess I just don't know what I'm
> doing.  I'm sure this is very simple.  Any help would be
> appricitated.  If I'm being vauge, I'm sorry.

The simple way would be something like this:
  fNum& = FREEFILE
  OPEN Character.Name$ & ".dat" FOR BINARY AS fNum&
    PUT #fNum&, , Character.Strength%
    PUT #fNum&, , Character.Intelligence%
    PUT #fNum&, , Character.HitPoints&
    PUT #fNum&, , Character.Mana&
    '[etc.]
  CLOSE
To read it back in, do the same thing, just replace "PUT" with "GET".

Bear in mind, while this is one of the simpler ways to do this, it 
isn't the *only* way, and probably not the best way. ("Best" depends 
upon your requirements, of course.) This also doesn't take into 
account things like compression and encryption.

On a side note, if you're writing a roguelike (as suggested by your 
nym), you may want to visit rec.games.roguelike.development for ideas 
and other such things.

-- 
Black hat bean-counters!
 




 4 Posts in Topic:
Freebasic, newb question about file operations.
Angbandit <manofsteel1  2008-02-26 07:22:37 
Re: Freebasic, newb question about file operations.
"Auric__" <n  2008-02-26 17:17:19 
Re: Freebasic, newb question about file operations.
Angbandit <manofsteel1  2008-02-26 10:29:30 
Re: Freebasic, newb question about file operations.
"Auric__" <n  2008-02-26 20:24:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 23:52:15 CDT 2008.