Hi all,
I am looking for the "best" way to store and retrieve level data ( number of enemy, speed, terrain mesh name, etc)
I use a struct to load in game, but where should I put them without using a file, or if I must use file, can anyone direct me to a snippet.
Thanks,
Robert
loading levels data
-
- Posts: 69
- Joined: Fri Feb 22, 2008 6:47 pm
- Location: montreal
- Contact:
loading levels data
If it can't be writen, it can't exist
Do you mean how can you do it without saving it to a file on your computer? Obviously you can't do it any other way (could use a database)... how would you imagine the data being 'saved' without it actually being written to disc? Once the game has been closed it would be lost if it were just kept in memory...
There's plenty of C/C++ tutorials on the net showing you how to read and write from files, google it!
There's plenty of C/C++ tutorials on the net showing you how to read and write from files, google it!
-
- Posts: 69
- Joined: Fri Feb 22, 2008 6:47 pm
- Location: montreal
- Contact:
I know about file I/O but...
Hi JP,
I have worked with file I/O, but now I want to save the data level in the source. I have made many tries with 2 dimensions array but none work correctly. An array of 10 x 5, that contains class object, int, vector,pointer,
I wan to initialize it in the code, so it s compile with code.
And I googledddd a lot
Thanks for the reply,
Robert
PS: sorry for the lexicon, I am Québecois
À la prochaine
I have worked with file I/O, but now I want to save the data level in the source. I have made many tries with 2 dimensions array but none work correctly. An array of 10 x 5, that contains class object, int, vector,pointer,
I wan to initialize it in the code, so it s compile with code.
And I googledddd a lot
Thanks for the reply,
Robert
PS: sorry for the lexicon, I am Québecois
À la prochaine
If it can't be writen, it can't exist
Okay, well JP just spelled it out for you. Everything piece of memory that your program is using is lost when it terminates. Now of course you could use SMC (Self-Modifying Code) if you were working on the assembly level. But even then, it is a bad practiced, and usually only used on low-end systems like the TI calculators, etc.
So bottom-line, use a file!
So bottom-line, use a file!
TheQuestion = 2B || !2B
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Re: I know about file I/O but...
How unfortunate.robertgarand wrote:Hi JP,
I have worked with file I/O, but now I want to save the data level in the source. I have made many tries with 2 dimensions array but none work correctly.
Super, go ahead and do so.robertgarand wrote:I wan to initialize it in the code, so it s compile with code.
What you are asking is:
1) Fundamentally trivial. Storing data in the executable's memory just requires that you declare an array containing those data.
2) So application dependent that I can't possibly guess why your current implementation isn't doing what you expect it to do. I have no idea what the significance of a 10x5 array is to your app.
The only thing that I can suggest is that if you're really storing "pointers" in your data and expecting them to be valid, then you're going to be sorely disappointed.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
It's REALLY starting to piss me off to read people saying "sorry, I'm X, this explains my bad English or what's not". Christian and I are both québecois too, do we have trouble writing or understanding English? No. Crap it, in Québec, it's the second language. In most countries, people learn up to 4 languages and keep practicing 3 throughout their lives. And if worst come to worst, it's not so hard to install a corrector plug-in for you favorite browser coupled with a dictionary. Just stop trying to justify your level in a language based on your nationality. Grrrrr.
Also, just try something like that:
savefile.txt : "Blahblahblah inc"
in your code : std::string savefile("Blahblahblah inc");
your loading function
load(std::string data)
or something similar. That way, it will make no difference whether it comes from a file or your code.
Also, just try something like that:
savefile.txt : "Blahblahblah inc"
in your code : std::string savefile("Blahblahblah inc");
your loading function
load(std::string data)
or something similar. That way, it will make no difference whether it comes from a file or your code.
-
- Posts: 69
- Joined: Fri Feb 22, 2008 6:47 pm
- Location: montreal
- Contact:
thx for the reply... SOLVED
This is what I was after:
It is much easier to modify when developping the game.
Thanks for the time you gave,
Regards,
Robert
Code: Select all
typedef struct
{irr::c8 *map;
irr::c8 *texture_map;
int max_shellc;
int max_jetc;
int max_tankc;
irr::f32 shell_speedc;
irr::f32 jet_speedc;
irr::f32 tank_speedc;
irr::core::vector3df gravityc;
}level;
level data_level[2] ={
{"scenes//sol_quad.ms3d", "textures//sol_quad.jpg", 5, 3, 0, 0.3f, 0.05f, 0.5f,
irr::core::vector3df(0.0f,-0.003f,0.0f)},
{"scenes//sol_mars.ms3d", "textures//sol_mars.jpg", 5, 7, 0, 0.03f, 0.07f,0.5f,
irr::core::vector3df(0.0f,-0.002f,0.0f)}
};
Thanks for the time you gave,
Regards,
Robert
If it can't be writen, it can't exist