🔒 Locked
Loading Screens
Advertisement
Original Post
Okay just to make this clear i'm not asking on how to display a loading screen, or how to show a loading bar, to even match up with the loading progress. My Question is how do i create a loading screen. What Code goes behind the "loading" function, and how it works. i've seen many people say to set up a loading screen type the following. StartLoading(); PlayGame(); EndGame(); This doesnt help. since i dont know what goes behind the StartLoading function. Is there any tutorials out there or some sample code of loading data. I currently have a small Game engine i have built and i am noticing some lagg. I'm presumming this is because i have no loading screen to store all the data into ram before running it.
Well, what I would recommend, and is what I've done before, is thus:
Load Stuff needed for the game to start (menu, required sound effects, etc.)
Display Loading Graphic
Load Needed Textures
Load Needed Models
Load Needed Sound Effects
etc.
Go to menu loop
When loading a level / starting a new game / etc:
Display Loading Graphic
Load Level
Load Models
Load Textures
Load SFX
etc.
Go to game loop
The loading screen itself isn't special, it's just something there for people to look at while your game calls all of its loading functions / opens models and textures.
Simply put, display the image, then load all of your stuff, then go on to other parts of the game.
Really, it shouldn't cause any lag in game unless your functions are loading data constantly, when it could be done all at once at start up.
Sorry, don't really know any better way to put it.
Load Stuff needed for the game to start (menu, required sound effects, etc.)
Display Loading Graphic
Load Needed Textures
Load Needed Models
Load Needed Sound Effects
etc.
Go to menu loop
When loading a level / starting a new game / etc:
Display Loading Graphic
Load Level
Load Models
Load Textures
Load SFX
etc.
Go to game loop
The loading screen itself isn't special, it's just something there for people to look at while your game calls all of its loading functions / opens models and textures.
Simply put, display the image, then load all of your stuff, then go on to other parts of the game.
Really, it shouldn't cause any lag in game unless your functions are loading data constantly, when it could be done all at once at start up.
Sorry, don't really know any better way to put it.
Yeah. Just use whatever you like to load your textures and stuff. If you have a loading bar, then load some textures, update the loading bar, and call a render from within the loading function to display the new progress bar. That's what I do. Don't know a better way to explain it. It should be pretty intuitive, I think...
Ah, loading :) A couple years ago I was confused about when and what to load too...
Without any information on what type of engine you are writing (or even what API you are using!), I can't get too specific... but essentially this is what gets loaded before you allow the user to play the game:
1) All 2D objects (user interface objects, and anything else you are using sprites for).
2) All 3D objects (meshes, textures for the meshes, materials, etc.)
3) All Sound Effects and or Music
4) Any and all enemy objects, item objects, player objects, etc. etc. (essentially, any objects in your first "level").
NOTE: They don't have to be loaded in that order.
NOTE2: I tried to refer to everything as an "object", as I hope you have a class or something wrapped around every "element" above.
In other words, let's say you have a mouse cursor object called "MCursor" which contains a D3DXSprite for its artwork, and it keeps track of its current position. When I say "load all user interface elements", I mean you should (dynamically, is what I suggest) allocate memory for those objects. i.e.
MCursor* mouseCursor = new MCursor;
So that line, for example, should be in your load function. So should everything else in your first level that will be used/viewed/whatever.
Hope this helps,
-dbh
Without any information on what type of engine you are writing (or even what API you are using!), I can't get too specific... but essentially this is what gets loaded before you allow the user to play the game:
1) All 2D objects (user interface objects, and anything else you are using sprites for).
2) All 3D objects (meshes, textures for the meshes, materials, etc.)
3) All Sound Effects and or Music
4) Any and all enemy objects, item objects, player objects, etc. etc. (essentially, any objects in your first "level").
NOTE: They don't have to be loaded in that order.
NOTE2: I tried to refer to everything as an "object", as I hope you have a class or something wrapped around every "element" above.
In other words, let's say you have a mouse cursor object called "MCursor" which contains a D3DXSprite for its artwork, and it keeps track of its current position. When I say "load all user interface elements", I mean you should (dynamically, is what I suggest) allocate memory for those objects. i.e.
MCursor* mouseCursor = new MCursor;
So that line, for example, should be in your load function. So should everything else in your first level that will be used/viewed/whatever.
Hope this helps,
-dbh
Oh, and one more thing.
I don't think your slowdown problems are because of a loading issue. That is, unless you are actually loading things during your gameplay?
In other words, does your game actually load new objects (art, enemies, anything) while you are playing?
If it doesn't, that definitely isn't your slowdown problem. If you are, you should really try and put all of those initial loads into a LoadLevel() function of some kind.
Don't go too crazy on this, either... certain things SHOULD be loaded only the fly... like particles, for example. Let's say your game has a gun that fires bullet particles. You would want to load the gun(s) before the level starts (allocate memory for the gun object and any artwork it uses, if it hasn't been loaded by another gun already created) and also the artwork that the bullet particle uses. BUT, you do not need to load the actual gun particle itself... that can be (and should be, I think) dynamically allocated whenever the gun fires. Make sense?
-dbh
I don't think your slowdown problems are because of a loading issue. That is, unless you are actually loading things during your gameplay?
In other words, does your game actually load new objects (art, enemies, anything) while you are playing?
If it doesn't, that definitely isn't your slowdown problem. If you are, you should really try and put all of those initial loads into a LoadLevel() function of some kind.
Don't go too crazy on this, either... certain things SHOULD be loaded only the fly... like particles, for example. Let's say your game has a gun that fires bullet particles. You would want to load the gun(s) before the level starts (allocate memory for the gun object and any artwork it uses, if it hasn't been loaded by another gun already created) and also the artwork that the bullet particle uses. BUT, you do not need to load the actual gun particle itself... that can be (and should be, I think) dynamically allocated whenever the gun fires. Make sense?
-dbh
i'm not quite sure. my code has become quite messy. but it shouldnt. But i think it might be. Because when i run the app. Ir runs smoothly, after like 1 min it slows down, then speeds up. Then repeats. does it every 1 min or so. so i'm guessing it might just loadind during game play. I'm just going to add a few printf functions to see what functions are being constantly loading.
BTW its writting in C++ with an OO Framework. Using the OpenGL API.
BTW its writting in C++ with an OO Framework. Using the OpenGL API.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement