Tag Info

Hot answers tagged

101

As the quote says, many programmers make the mistake of (trying to) build a system, not a game. Typically that system keeps ballooning out of control until it's so complex that theoretically it can handle anything, but in practicality all you have is a big bundle of code. Or more often, before you even get to a working stage, you are so tangled up in code ...


96

Now for a less flippant response, with some suggestions. Don't take these as implementation recommendations, more as examples of possible use. Builder: set up component-based entity one component at a time, based on data Factory Method: create NPCs or GUI widgets based on a string read from a file Prototype: store one generic 'Elf' character with initial ...


39

You call it 'diligent software development', I call it 'painful overengineering'. That's not to say that inversion of control is bad - in fact, the basic definition of it is good - but the proliferation of entire frameworks and methods of working to achieve all this is little short of insane, especially combined with the way people are trashing perfectly ...


30

These things can always be useful. Whether or not it's the prettiest or safest solution is another matter, but I think game development involves a certain degree of pragmatism.


24

I started writing a book on exactly that topic: Game Programming Patterns. It's unfortunately on hiatus right now, but the chapters that are there might be helpful for you.


23

Here's my original answer to a similar question on SO from a while back, at least concerning the MVC part of your question: It's rarely used in games. It took me a while to figure out why, but here's my thoughts: MVC exists to make a distinction between two representations. The Model is the abstract representation of your data. It's how the machine views ...


20

adding too many features. Focus on the core of the game, build it, then if everything works well then add features. People get too focused on adding cool things, and never getting anything done.


20

You want to separate update (logic tick) and draw (render tick) rates. Your updates will produce the position of all objects in the world to be drawn. I will cover two different possibilities here, the one you requested, extrapolation, and also another method, interpolation. 1. Extrapolation is where we will compute the (predicted) position of the object ...


19

There is no one perfect mapping that gives you a platform specific abstraction, because obviously most of the identifiers that make sense for a 360 controller are wrong for a PlayStation controller (A instead of X, B instead of Circle). And of course a Wii controller is another thing altogether. The most effective way I've found to deal with this is to use ...


19

Game Engine Architecture has some information regarding this topic. The basics are that you need to do some analysis to understand what your memory requirements per level/frame/etc. are like, but there are a few patterns the author mentions having seen several times: Stack-based allocators: These allocate a large segment of memory once, and then allocate ...


18

These names vary by region, company and developer. Most of them are made up and are often just synonyms for "thing". Create names that describe the purpose of the code. A frame rate clock is called a frame rate clock. There's no dictionary for these things. You can't have a dictionary if the objects you're describing don't have a firm definition. The ...


17

Strategy Pattern, Composition, Dependency Injection, are all very closely related. Since the Strategy Pattern is a form of Dependency Injection, if you take a look at engines like Unity for example they are completely based off this principle. Their use of Components(Strategy Pattern) is deeply embedded into their whole engine. One of the main benefits ...


17

You totally don't need to hand-code combinations. You can instead focus on the properties that each item gives you. For instance, Item A sets Projectile=Fireball,Targetting=Homing. Item B sets FireMode=ArcShot,Count=3. The ArcShot logic is responsible for sending out Count number of Projectile items in an arc. These two items can be combined with any ...


16

Then there's a greenlight, and in an effort to clean things up, somebody writes a GameManager. Probably to hold a bunch of GameStates, maybe to store a few GameObjects, nothing big, really. A cute, little, manager. You know, as I was reading this, I had little alarms going off in my head. An object with the name "GameManager" is never going to be cute, ...


16

I don't think there's one accepted way of implementing this concept, but I'd really like to share how I usually deal with this in my games. It's a bit of a combination of the Command design pattern and the Composite design pattern. I have an abstract base class for actions which is nothing more than a wrapper around an Update method that gets called each ...


14

Definitely a non-exhaustive list, but here goes: Cons Lifetime management. Singletons and globals may like to start up before key systems (e.g. heap) are initialized, depending on how you set them up. If you ever want to tear them down (useful if you're doing leak tracking, for instance) you have to be careful about the teardown order or start getting ...


14

Yes, it is. Allocation time isn't the only factor. Allocation can have side-effects, such as inducing a garbage collection pass, which can not only impact performance negatively it can also impact performance unpredictably. The specifics of this will depend on your language and platform choices. Pooling also generally improves locality of reference for the ...


14

There's no industry standard, but most high-profile studios do create a game design document. Game development, after all, encompasses quite a number of fields, so there will often be a combination of storyboarding, UML for the programming side, a script for dialogue, and so on. That being said, the number one "modelling language" I've encountered: flow ...


13

This is a great article about how to prototype a game. From your question is seems like you're missing the idea of what a prototype is supposed to be. Prototyping: You’re (Probably) Doing It Wrong Blurb: Mistake #4: Building a system, not a game When you’re making a prototype, if you ever find yourself working on something that isn’t directly moving ...


12

Because MVC doesn't fit in the architecture of a game. The dataflow for a game is entirely different than that of a enterprice application, because it's not as event driven and there is often a (very) tight millisecond budget in which to perform these operations. There are a lot of things that need to happen in 16.6 milliseconds so it's more beneficial to ...


12

You should have a very well-defined set of interfaces that are allowed to transmit or receive messages -- giving them a reference to a EventScheduler should be trivial. If it isn't, or if you feel like that would involve passing the event scheduler to "too many" distinct types, then you might have a larger design problem on your hands (a promiscuous ...


11

You already accepted an answer, but here's my stab at a CBS. I found that a generic Component class has some limitations, so I went with a design described by Radical Entertainment at GDC 2009, who suggested separating components into Attributes and Behaviors. ("Theory and Practice of the Game Object Component Architecture", Marcin Chady) I explain my ...


10

The time spent eliminating false paths is not wasted. It's time well spent, learning about what the right design is for your particular game. If you're willing to throw that out, that puts you WAY ahead of the game compared to most novice designers. Think of it this way. When you first set out to make a new game, you either know EXACTLY what mechanics work ...


10

What about a component-based engine? You would have a main class named Engine, which would keep a list of GameScreens, which would themselves hold a list of Components. The engine has an Update and a Draw method and both call the GameScreen's Update and Draw methods, which themselves go through every component and call Update and Draw. Presented like ...


10

The strategy patterns seems like a good bet to me. To take it a step further, your camera manager should remain ignorant of the concrete camera types. You would register and change camera implementations externally by id (I used a string for flexibility but could be an enum or an int too), for instance (without any error checking): public interface ICamera ...


9

There seems to be a lot of confusion about the Inversion of Control (IoC) pattern. A number of people have equated it with the Strategy Pattern or a Component Model, but these comparison don't really capture what IoC is about. IoC is really about how a dependency is obtained. Let me give you an example: class Game { void Load() { ...


9

I'm working on a TCG myself, so I have a little bit of experience with it. I would have a base "Card" table which would have the columns common to all cards, such as Name, Description, CastingCost or whatever. Then for each type you'd have the type specific columns which would foreign key to the Card table. The CardId can be both PK and FK in the ...


9

I'd never heard of domain driven design before your post. A quick look at a couple of references - here and here - seem to suggest that it's just a fancy name for the traditional 90s method of object-oriented programming that I was taught in university, where you try and write classes for each noun that appears in the situation you're trying to model with ...



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