Loading...
Tomoso

Just a quick question.
In many games (probably all that are commercial) there is a loading screen. I was just wondering why would I need one for my game?
I know that may seem like the dumbest question ever, but what would I actually "loading" if I had one.
At the moment I haven't bothered implementing any sound into my game, since my PC lacks a sound card :P and the memory I use while the game is running is handled, well, while its running.
For Example: Add and enemy\bullet to required linked list and destroy them when they die or leave screen etc...

My images are all packed into a DataFile and are updated onto the buffer as such:

// Draw Ship Sprite to Screen
     draw_sprite(buffer, (BITMAP*)datafile[ship4].dat,m_X,m_Y);

Is that right? Or should the images from the data file be loaded into memory bitmaps say at the start of the level and then loaded that way. I'm not sure if that would be faster. Or even worth it.
Hope you understand what I'm getting at :P
Thanks,

Richard Phipps

You could have a seperate "loading text" bitmap which you load first and display to the screen. You then could load all the other images, sounds and music files you need while the player is looking at the loading screen.

miran
Quote:

I know that may seem like the dumbest question ever, but what would I actually "loading" if I had one.

You would be loading images, sounds, music and videos. You could also be precalculating things that aren't stored in files but can be calculated from mathematical models before the main loop so you don't have to calculate them during gameplay.

ixilom
Quote:

I was just wondering why would I need one for my game?

The only reason for having a "loading screen" is when you know for sure its going to take a while to cache images/sounds and precalculate stuff. For a simple game with 20 images or so, its not necesary.

Think of games like Half Life, Quake. They need to load/cache hundreds of textures, load map coordinates for planes etc. A Quake map can be 1mb to XX mb big with only x/y/z cordinates that build up the floors,ceilings,walls, details etc.

Tomoso

OK, but
is this the right way to do things?

// Draw Ship Sprite to Screen
     draw_sprite(buffer, (BITMAP*)datafile[ship4].dat,m_X,m_Y);

or should i load that into another bitmap?
All my bitmaps are in the data file so everything is "loaded" from there.

Kitty Cat

That is fine.

Johan Halmén

load_datafile() loads everything from the datafile to the ram memory, right? And after that you don't gain any speed by loading the bitmaps to other bitmaps, right? I have never done this, but I need it for my next game. I'm thinking of a following kind of structure:

DATAFILE *startupscreen, *data;

...

startupscreen = load_datafile("data1.dat");
blit((BITMAP*)startupscreen[0].dat, screen, 0, 0, 0, 0, 1024, 768, 1024, 768);
unload_datafile(startupscreen);

data = load_datafile("data2.dat");
// other stuff, precalculations, lookup tables...
...

Felipe Maia
Quote:

load_datafile() loads everything from the datafile to the ram memory, right? And after that you don't gain any speed by loading the bitmaps to other bitmaps, right?

You won't loose hardly any speed if you doBitmap *first = startupscreen[0].dat;

[edit]
It is also good to add that most commercial games will load some things out of the CD and not from the HD, which makes it a lot slower.

Tomoso

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:

DATAFILE* m_pEnemyData = load_datafile("Data/datafile_enemy.dat");

This should only load it once since the class is created only once :P
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.
Thanks

Felipe Maia

You're probably doing something wrong. A reference copy is really fast. You shouldn't need to have a copy for every enemy you create, except if they're different (i.e: each enemy has a different datafile). You could have a static class or something like that that will use the datafiles, instead of the objects themselves. This won't make your game faster though, but it will use less memory depending on what you have.

Tomoso

Thanks, instead I loaded all the datafiles within the constructor of the GameEngine class and passed them through to their respected owners as they needed to be drawn. Except now I have some other wierd bug that just crashes my program if the player doesnt create a bullet before the enemy 8-) oh wells, my first speed hack now >.<
I'll sort it later :P

Thread #586821. Printed from Allegro.cc