Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Crazy Chicken

C++ I/O help needed...

This topic is 5203 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am currently working on a 3D flocking application for my university project. But in order to give the user control over the flocks without having to look through the code I would like to use a text file where all relative data can be editied. When reading the file I am only interested in the values and not the text which is just there so that the user knows what he is changing. I have some understanding of file I/O but I would appreciate it if someone could maybe offer me some help of how I could solve this problem cause my books have not helped !!!! I want the file to look something like this... /////////////////////////////////////////////////////////////////// Flock1 { Number = 10 Max Speed = 2 Desired Speed = 1.5 Max Acceleration = 0.5 Perception Range = 20 Y-Axis Constraint = 0.5 Seperation Distance = 15 Max Boids Visible = 10 Color: red = 0 green = 200 blue = 0 } Flock2 { Number = 20 Max Speed = 1.0 Desired Speed = 0.5 Max Acceleration = 0.1 Perception Range = 30.0 Y-Axis Constraint = 0.99 Seperation Distance = 10 Max Boids Visible = 10 Color: red = 200 green = 0 blue = 0 } /////////////////////////////////////////////////////////////////

Share this post

Link to post
Share on other sites
The simplest method would be to create an INI file using win32 functions to read back info: GetPrivateProfile Section, GetPrivateProfileString and GetPrivateProfileInt. The INI file presentation is very close to what you are looking for:
Key1 = data
Key2 = ...

Another method would be to code a simple file parser using filestreams and string streams: look at gamedev articles in the Languages section (Simple File I/O using C++).

Hope that helps.

Ghostly yours,
[EDIT: clarified a bit the INI file structure]

[edited by - Red Ghost on April 22, 2004 11:27:04 AM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!