Hot answers tagged loading
39
Simple answer: the game is divided into chunks, while you move around chunks are constantly being loaded behind your back before you can see them and thrown away when you leave the area. To every simple answer is a complex solution that weighs innumerable trade-offs in implementation... but you get the idea.
For games where you think you can see tens or ...
12
The typical things to pre-load is anything that you're going to need in realtime. Save for concepts like clipmaps and megatextures (where the idea is to load the parts you need, and iteratively update it as you move around in the world), you're going to want to keep everything you need for your level/area/whatever in memory rather than on disk. IO is ...
10
Previous answer pretty much nails it all. Also worth mentioning is Dungeon Siege I.
Here's a paper from one of the developer which actually goes over some of the architecture needed to make it work and common pitfalls:
http://www.floatingorigin.com/mirror/continuous-world.htm
I'd say it's a must read if you actually want to implement something like that.
10
DrawableGameComponent's come with a certain amount of overhead - aside from the memory, every time you add a component to the collection it must be resorted (because components have a DrawOrder). You don't want to be constantly adding and removing components.
For this reason, you don't want Bullet to be a DrawableGameComponent. Instead, you should make ...
9
Assimp seems to be a good choice and I will be testing this with my next project. It supports a huge array of formats including supporting bones and animations. Not just for model loading, but for changing from format to format, computing vertex and face normals, splitting meshes, and triangulating polygons. It is available under the BSD license.
8
Basically, I'd say that during the "Loading" process the game tries to load and precompute all operations that cannot be done in runtime. For example, retrieving images (to be used as textures) for the hard drive is usually a slow process. On the "Loading" step these images can be copied to RAM memory, which is muuuuch faster access storage, enabling ...
7
First of all: how you do it doesn't really matter. Just do the very simplest thing that could possibly work. My current favourite way is with static methods in each class (ie: bullet, ship), like this:
static Texture2D myTexture, myOtherTexture;
// Call me from Game.LoadContent:
public static void LoadContent(ContentManager content) { content.Load /* ...etc ...
7
For now, since calculating the paths mid-game is unnoticeable, that is the ideal approach. If / when it gets to the point where gameplay is interrupted by the calculations, then switch it over to per-calculating the paths before the level is loaded.
Longer initial loading times are forgivable, but random FPS fluctuations during play generally aren't.
7
The general approach is called hysteresis: instead of immediately changing when you cross a border, you change only after you are some distance past the border.
For the simplest example, suppose you want to draw a warning on the screen if you are too close to something. The straightforward code is:
if distance < 20:
draw warning
But if you're ...
6
Minecraft is a 3D game with a game world that is extremely large in size (practically infinite). Instead of 3D terrain derived from meshes, the terrain is represented by 3D Cubes. The world is procedurally generated and stored in small chunks, similar to what you described in your first potential solution.
While playing Minecraft, chunks near the player ...
5
I've studied the DOOM source code a bit. I'll tell you how it's done in there.
D_DoomMain contains all of the open/save/load functions, as well as a slew of other things. As it says at the beginning of the file,
// DESCRIPTION:
// DOOM main program (D_DoomMain) and game loop (D_DoomLoop),
// plus functions to determine game mode (shareware, ...
5
The simplest texture manager has one function: GetTexture. GetTexture checks its cache for a texture. If the texture isn't cached, it loads the texture. Then it returns the texture. Kapow! Done!
That is sufficient for most small-scale indie games I've seen. You just don't have enough content for this to ever be a problem.
One downside is that this can ...
5
Premature optimization is the root of much evil.
If your goal is loading-time prediction, I would say leave the OS file-caching in place. It's probably general, but well-written, so I would say that you shouldn't disable it unless:
You have a very good reason to do so, and
You can measurably prove that disabling it is beneficial in your case.
...
5
BerickCook has expressed the idea correctly. Leave the calculations where they are if they work properly now.
If you can do the calculation before and you are sure you will not need them mid-game, then do it before. Else do it after loading.
If the calculation during the game is unnoticeable you could do it there. If at some point the complexity evolves and ...
4
I'd say this really depends on what type of game you're making, but some general points.
Only load what you absolutly know you need immediatly, or you know you'll need soon
Only remove things from memory when you absolutly know you wont need them again AND you need to load something that fits the constraints of #1 AND you've reached your memory limit
A ...
4
As the commenter said: check to see if your app runs fine when running as administrator, because if it does, that suggests something different.
Otherwise, I think you're running into a straightforward access rights issue. You don't, as a rule, have the right to open any files under "C:\Program Files" with write access. So you don't get to save any files ...
4
I don't know how this feature would be implemented in your specific development environment, but the solution to the problem you describe is masking.
Basically, apply a mask to the progress bar in the shape of your letters and then the stretched rectangle won't be rendered outside the mask.
4
It's been a while since I used C#, but I think you can structure your class something like this:
public static class Tile {
public static enum TileType {
Air,
Stone
}
public static bool IsSolid(TileType tile) {
switch(tile) {
case Air:
return false;
case Stone:
...
3
Initialization should not happen in the game loop, you'd end up loading the same resource over and over again.
For a resource like an image associated with a class you should make a static field for holding the reference to the resource. You must load the resource only once. You could do this separately, or you could check during instance initialization if ...
3
Could you open all of the images before you start the slide show? Store them in an array of textures and then just loop through?
If not, then I would suggest using the c# threading classes Josh Petrie suggested, or using the Thread class itself, which can be easier to use than it looks.
If you are new to threading I would suggest avoiding it unless you are ...
3
Depends if you're going for one loading screen and instant level transitions or multiple loads.
I would say that the latter would be better on memory.
Something like:
//First loading screen
Load menu layouts or whatever
Load GUI assets
Show something to pass the time
Switch to menu
//In between levels
Remove any graphics specific to the last level - get ...
3
You could serialize the class or the data to a flat file and then read it back when you load.
3
I would've gone for the asset manager having a stack of data it needs to load. If there's an easy way to go about it, there's the option of adding to a size counter as you add elements to the stack - this means you could increase varyingly. So instead of a large texture and a quick sound effect both increasing loading by 10% say, it could increase by 13% and ...
3
The easiest way will be load obj files, like so(files you are interested in -> glm.h/cpp):
http://www.xmission.com/~nate/smooth.html
It comes with examples.
I personally feel, that if you are learning, you should make one yourself. Not as feature filled as above, but a simple obj loader that reads vertices/normals/texture co-ords and perhaps the material ...
3
Saved games should either:
Completely describe everything, whether mutable or not. This is the safest way, and easy, but does use a lot more space. It doesn't really use more memory, since you need the trees either way. It just uses more persistent storage, which there is plenty of on anything that's not a Nintendo DS. It also means you can't fix bugs in ...
3
I'd say no. Windows will be using spare memory for this caching - it's basically free. Unless you've got a fancy system to somehow expand your process memory to cache more data when Windows is under low load, and then contract it again when Windows decides it wants more memory, just let the computer do what it's good at it.
I don't think increasing load ...
3
If the loading screen is rendering, make sure it is not also locking resources which the loading thread needs to use.
Easy way to tell if the loading screen is chewing up resources due to rendering too often - put a 1000ms Sleep in the render loop of the loading screen, and see if your loading performance comes back to normal.
3
Well first off you loop through the entire array, when you only want one customer. If you only want, say, mcArray[2] then only manipulate that value, don't loop through the entire array.
More generally however, it looks like you are writing the code outside of any function, which doesn't make any sense in this case and even in situations where it works it ...
3
Yes, this can be solved with multithreading. Either explicitly by creating a new thread which reads and interprets a file, or implicitly by using an asynchronous file access API which calls a callback function when a file finished loading.
The biggest problem with loading assets on demand is what to do when an asset is needed immediately, but it hasn't ...
3
Your process is generally the right idea for a basic, generic multi player game without any specific design goals. However, there is a lot of stuff you should keep in mind that the client/server does not need to be doing. I'm going to list your steps again and annotate them.
Client sends "iwanttologinwithcharacterx"
Yes, this is an obviously needed step. ...
Only top voted, non community-wiki answers of a minimum length are eligible
