63

Same as all average programs: They don't.* For most applications there is no customer expectation that they continue working once memory runs out. All games fall under these "most applications". Spending time and money to work on an edge case which the customer doesn't expect to work doesn't make sense. The question is similar to the following: How do you ...


23

A semi-common approach is to make what I call shader components, similar to what I think you're calling modules. The idea is similar to a post-processing graph. You write chunks of shader code that includes both the necessary inputs, the generated outputs, and then the code to actually work on them. You have a list which denotes which shaders to apply in ...


23

Typically this kind of scenario never happens. Firstly, virtual memory on modern operating systems means that it's highly unlikely to happen in normal operation anyway; unless you have a runaway allocation bug, the game will be allocating memory from the OSs virtual address space and the OS will be looking after paging in and out. That's all well and good, ...


19

Lots of games have a generic "error material" and "error mesh" that is really obvious to see. Pair this with a warning in the logs, of course.


16

Modern open-world games simply don't fit in memory. Keep in mind that most games are still 32-bit due to the number of gamers with 32-bit OSes, and a 32-bit process at best can only have 4GB of addressed memory at a time (independent of virtual memory) but realistically is limited to 2-3 GB. Toss in fragmentation and the actual amount of usable objects you ...


12

You mean games like Ogame? In my opinion it is best to calculate the value when it is needed, not on a regular event as Jari Komppa suggested. You could even go a step further and calculate the value on a client side sometimes. In case of Ogame: Imagine that server increases amount of resources every minute for millions of users (where probably half or ...


8

Smart pointers or handle classes, just like C++11. You could write your own long before C++11. I would even argue that the shared_ptr in C++11 is probably the wrong model entirely. All you do is make a type that holds a reference to a resource. This reference could be a pointer with some kind of lifetime management or it could just be some kind of numeric ...


6

If you have different resolution assets of the same texture, you could try to salvage the situation by using a different resolution. Texture* grassTexture; try { grassTexture = LoadTexture("Grass.png"); } catch (WhateverExcaption e) { grassTexture = LoadTexture("Grass_512.png"); } If even that fails, it might be time to bail.


6

https://stackoverflow.com/questions/50945/can-you-do-a-partial-checkout-with-subversion Specifically, not everybody has to check out the whole tree. TortoiseSVN has a pretty user-friendly GUI for this. You can tell people to not check out certain folders (for example, programmers could skip the art source folder). Depending on your exact directory ...


6

You could change the GameObject's hideFlags? I just tried running this: GameObject myGameObject = new GameObject (); myGameObject.name = "Obvious Name"; myGameObject.hideFlags = HideFlags.HideInHierarchy; ...and it's there, but it's not in the hierarchy. Technically, it's in the scene, but you don't see it until you change it's flags back to HideFlags....


6

For a 32-bit game, as most games are for a variety of reasons, even a game that comes on one single-sided DVD (4.3GB) already has far more content that can be fitted into a 32-bit address space. And that's assuming the content isn't compressed on disc, and a perfectly optimal, load everything at once into contiguous address space approach. Many games now ...


6

So the other answer is good, but I will say this. In C++ the RAII idiom means "you never type object.close() or object.free() or object.release() or anything like that, it is a bit laxer on initialisation because of assignment operators. Suppose we have the following class Object { public: Object() { /* CANNOT doStuff after this, as it isn't ready*/ } ...


5

Short answer: Don't! Longer answer: OK, you are trying to compute complex path-planning, for multiple suppliers and demands. This is presumably going to involve some kind of peon/slave or worker/robot unit. However, in the same breath, you say you've got limited CPU resources. I'd suggest you take a note from Shamus Young and figure out what you actually ...


5

First of all, don't listen to people who say that Java is a bad language for making games in. Everybody should start their game development career by using the tools you're already familiar with. It seems your animations are entangled with your images, which makes it difficult to share animations between objects. I propose that your animations should not ...


5

Back in the days of C and no templates... we had void pointers. Good thing they weren't made obsolete, because you have just seen that templates aren't omnipotent gods. This situation is perfect for some void pointer hacks. Here, I tried to make an example that was as simple as possible: Edit: The example below makes a dangerous use of shared_ptr, please ...


5

The job queue system in Prison Architect is actually far more complex than a pure first-in-first-out queue. Actors prioritize their jobs: They only take jobs they are actually qualified for (example: any staff member can perform the "open staff door" job, but only guards can do the "open jail door" job) In many cases they prioritize jobs given by the player ...


4

You could create specific classes for each level which inherit from ContentManager, and use a LoadContent() method in each, to override the base LoadContent() call. You might also want to look at XNA's GameComponent class which itself inherits IDisposable. If each level was defined as a drawable game component, handling the disposal of each texture tilemap ...


4

I think you need to rethink what problem you're trying to solve and if that problem really exists. As far as I can tell your game is small enough to keep all assets in memory on any modern computer, have you measured your peak memory usage? (A quick and dirty way to do this is by checking the value of 'peak working set' in the task manager (be sure to ...


4

As with so many things, the answer is "Depends" Do you need to load a couple of hundred megs of data quickly? Are you streaming data in as the player traverses the level? Are you reading from optical media? If the answer is "yes", then pre-packed resource streaming is for you. If you're just making pong. It's not really a big issue, loading flat ...


4

I disagree with Vittorio about not needing shared ownership of resources and, while I dislike the implementation of shared_ptr, it can be made to work just fine. You want shared ownership because, of course, multiple game objects might be using the same resource. More importantly, if you have multiple levels and want to minimum level loading, you need some ...


4

The asset bundle system does not automatically remove anything nor does it load dependencies automatically. Dependencies are included in asset bundles automatically, but actually exist in each asset bundle that depends on them, unless you manually removed them. For example, if you have a 2 different player models, Hero1 and Hero2. They both share a Gun ...


4

I can give you only general information, based on my own experience. I have worked on AAA game engine development, but as a graphics programmer I was never involved with loading assets efficiently. We already had a system for that. Yes, streaming assets in from disk should happen on a separate thread (or a few) and never on the same thread as your game ...


3

I think (from your description), that svn externals will be correct answer: You have not copy object from repo to repo - you have single object, which is linked to and can be used from different targets "Thin" final repositories can be just any (only) collection of externals to the repositories, which holds data: you have additional flexibility in building ...


3

You should avoid allocating and deallocating resources multiple times per frame. Instead, you should create a single "brick" volume (or how ever many you need concurrently to perform a single Draw call) with usage type DYNAMIC. Then use Map with DISCARD flag to update the contents on the fly. Regarding the problem with your current approach, this is ...


3

But what happens now when I have a RenderTarget class that derives from Texture? I highlighted the problem with your design. A RenderTarget is not a Texture. It has a Texture. The RenderTarget is just a view (either literally as in ID3D11RenderTargetView in Direct3D or as an FBO in OpenGL) into a Texture. There's some potential issues with flags when ...


3

The String you pass to setTextureName() has a special format which isn't very well documented. If you just pass it a filename such as roly_block, it internally gets changed like so. No mod is specified, so it assumes it's a default Minecraft file, and as you're calling it from a Block class, it knows you're talking about a Block texture and all textures are ...


3

The nomenclature here is definitely odd. I at first thought you were talking about something lower level (like the scenegraph or screen manager for organizing logic flow and/or rendering). I then realized you are talking about what I would refer to as game state. Scenes are a popular term for it now with Unity, so I could see why you would call it ...


Only top voted, non community-wiki answers of a minimum length are eligible