Tag Info

Hot answers tagged

10

I won't discuss about the evilness behind singletons because Internet can do that better than me. In my games I use the Service Locator pattern to avoid having tons of Singletons/Managers. The concept is pretty simple. You only have one Singleton that acts like the only interface to reach what you used to use as Singleton. Instead of having several ...


8

You should consider shader programs as similar part of the state as textures. Changing the state is expensive, so you may be able to get away with combining several textures to one to avoid texture changes; the same applies to shaders - you may be able to combine several shaders to avoid state changes. Similarly to combining textures, combining shaders ...


7

I initialize my services in my main application class and then pass them as pointers to whatever needs to use them either through the constructors or functions. This is useful for two reasons. One, the order of initialization and cleanup is simple and clear. There is no way to accidentally initialize one service somewhere else like you can with a ...


5

From a performance standpoint, having data in memory is orders of magnitudes faster than having it in a database. There are two reasons to put data into a database instead of storing it in memory: You have more data than fits into memory You want to make sure no data is lost in case of a (intentional or unintentional) server shutdown As you already said, ...


3

It's best to keep things as simple as possible. Duplicating the same shader for every object is unnecessary and will quickly get bloated. You also don't want one giant shader that covers every possible use-case, as this causes unnecessary overhead. There are several opinions on shader management and no "optimal" way to approach this. I've even seen some ...


3

You really don't have much choice. Ignoring some (IMO) terrible other options, you can either: a) couple your behavior to specific animations - so artists don't make one attack animation, they make several that your behavior plays at the appropriate times or b) have animations emit events and export state variables that game logic is driven from - ...


3

I wouldn't bother that much with trying to fit the game in the mold that comes with MVC or any other pattern until I know for sure that it's the simplest way to develop it. Especially since most of the time you'll implement multiple known patterns in the same program, or alter patterns after you notice they don't quite fit in your program the way they were ...


2

Your question is a bit wider than you exposed I think. Player and Map are two objects and should be thought as it. They are not different, from an engine point of view, of a ping-pong table or a flying toaster. That said the question is : how to make NORMAL objects findable and communicate? For a map / player relation I usually put responsability... on a ...


2

Singletons to me are ALWAYS bad. In my architecture I created a GameServices collection that the game class manages. I can search add to and remove from this collection as required. By saying something is in global scope you are basically saying "this hting is god and has no master" in the examples you provide above I would say most of those are either ...


1

You could use an event system where you can have abilities and buffs emit and listen for events. In your example you could have a character emit a 'damage taken' event that contains the source and type of the damage upon taking damage. You can then listen for these events and if it was critical hit by a frost bolt, change the state of the character to ...


1

I've seen this done two ways for sure, and no doubt there are plenty of others I don't know about. Buffs directly add to stats. When they end they subtract their value from the stats. Buffs are tracked in an array or list and when the stats are relevant, the array or list is processed to find the current value. The advantage to the first is that it's ...


1

Your idea is correct, only render and update entities near the player for better performance. To do this in a efficient manner, you will need some sort of spatial partition to know what is near the camera. You definitely don't want to loop through all the entities on your map. One of the most efficient ways to use is a hash table, also known as a grid. But ...


1

We use a component class with optional interfaces for IUpdatable and IRenderable that tie into the scene container which handles the component life cycle (when the game engine core says "time to render", the scene container updates all the updatable components, then renders all the renderables). Since we construct lists of updatable and renderable components ...



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