OK, thanks, but just slightly changing the topic just a little. Yesterday night I decided to "clean" up my data files. Origonally I had one huge one that had everything. But it was a pain to update it since my PC is rly slow (288mhz;)).
I split everything into seperate files like - datafile_player.dat, datafile_enemy.dat etc.. etc...
For each I loaded the datafile when the class was created in its constructor, but realised that was a bad idea, since my enemies are created dynamically, and upon loading one of my levels where it creates 40 enemies right from the start it just froze my game until it had finished loading all of the datafiles for each.
So then I decided to have my GameEngine Class load the datafiles for all the different things, since that is the thing that is creating everything dynamically.
For Example, in my GameEngine Class:
This should only load it once since the class is created only once
Anyway, to solve the problem of having the enemy have its own datafile i pass the pointer from the GameEngine Class that points to the DataFile for the enemy into and enemy when its created, like so:
m_pCurr = new Enemy(x,y,type,direction,m_pEnemyData);
Which is then stored to a pointer within the enemy class itself.
I thought this would solve the "loading" issues, but I still have them. Before when I had everything in one file it was fast, but its still taking its time to load everytime an enemy is created (although not as severe). Surely though the pointer within the enemy class only points to the datafile the GameEngine already loaded into the RAM?
So why is it still taking its time to load something that has already been loaded?
Oops that was bit long winded for a simple question but oh wells.