Skip to main content

Questions tagged [design-patterns]

Design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.

Filter by
Sorted by
Tagged with
160 votes
8 answers
57k views

Why are MVC & TDD not employed more in game architecture? [closed]

I will preface this by saying I haven't looked a huge amount of game source, nor built much in the way of games. But coming from trying to employ 'enterprise' coding practices in web apps, looking at ...
timoxley's user avatar
  • 1,731
137 votes
9 answers
103k views

What are some programming design patterns that are useful in game development? [closed]

I have a few books on Design Patterns, and have read some articles, but cannot intuitively figure out which programming design patterns would be useful in game development. For example, I have a book ...
79 votes
10 answers
236k views

In Unity, how do I correctly implement the singleton pattern?

I have seen several videos and tutorials for creating singleton objects in Unity, mainly for a GameManager, that appear to use different approaches to instantiating ...
Zack Brown's user avatar
  • 1,459
55 votes
5 answers
14k views

How to avoid the GameManager god object?

I just read an answer to a question about structuring game code. It made me wonder about the ubiquitous GameManager class, and how it often becomes an issue in a ...
Laurent Couvidou's user avatar
43 votes
6 answers
8k views

When is the best time to consider performance?

I am coming from software development background. During the software development cycle, we usually focus on functionalities and the working product. At the end of development, we start optimizing ...
Emad's user avatar
  • 1,126
34 votes
8 answers
13k views

Do retail games use "inversion of control" and "dependency injection"?

Many of the more diligent software developers I know are moving to inversion of control and dependency injection to handle references to objects. Coming from a Flash games perspective I don't know all ...
Iain's user avatar
  • 6,548
25 votes
4 answers
6k views

"The Game Object" - and component-based design

I've been working on some hobby projects the last 3-4 years. Just simple 2d and 3d games. But lately I have started a bigger project. Soo in the last couple of months I've been trying to design a game ...
hayer's user avatar
  • 596
25 votes
2 answers
13k views

How to Interpolate between two game states?

What is the best pattern to create a system that all the objects positions to be interpolated between two update states? The update will always run at the same frequency, but I want to be able to ...
AttackingHobo's user avatar
24 votes
1 answer
6k views

Why should I always consider creating and using object pools instead of instantiating the new object on the fly?

I have read about this pattern several times (from a best-practices perspective): Memory Allocation: Instead of instantiating the new object on the fly, always consider creating and using object ...
Muhammad Faizan Khan's user avatar
24 votes
3 answers
22k views

Memory allocation patterns used in game development

I have been researching creating my own allocator methods (that will support things such as a memory pool and profiling), however, as I continue my research I have been looking for how this was done ...
chadb's user avatar
  • 485
23 votes
3 answers
4k views

Command Ordering Architecture of Dwarf Fortress

What is the most elegant way to implement a command ordering system for AI? for example in dwarf fortress when you mark a forested area for wood cutting, the dwarfs then would do the following ...
jedt's user avatar
  • 333
23 votes
2 answers
10k views

How to design context menus based on whatever the object is?

I'm looking for a solution for a "Right Click Options" behaviour. Basically any and every item in a game, when right clicked, can display a set of options based on whatever the object is. Right ...
Mike Hunt's user avatar
  • 341
22 votes
9 answers
9k views

How to create a user-friendly magic spell system?

I'm designing a small 2D top-down open-world survival-ish game with a magic spell system. The way it works so far: The player receives a "wand" at the beginning of the game As the player encounters ...
Nico A's user avatar
  • 321
20 votes
2 answers
3k views

Development pattern for interactive in-game tutorials

Interactive in-game tutorials often interrupt game flow and override standard behavior in a way that can be difficult to implement cleanly. For example, imagine we have an action game and we want a ...
Kevin's user avatar
  • 6,494
20 votes
3 answers
8k views

Design of a turn-based game where actions have side-effects

I am writing a computer version of the game Dominion. It is a turn-based card game where action cards, treasure cards, and victory point cards are accumulated into a player's personal deck. I have the ...
Apis Utilis's user avatar
19 votes
6 answers
1k views

What are the biggest pitfalls to consider when developing a new game?

I actually just started tracing (thanks David Young for the nomenclature correction) a couple of new web-based games for Facebook a few weeks ago and I have just been inundated with mental blocks and ...
angryCodeMonkey's user avatar
19 votes
3 answers
3k views

MVC-like compartmentalization in games? [closed]

I was contemplating the design of a game (translating a boardgame to the computer, specifically, which I suppose is relevant in this case) and it occurred to me that it might make sense to build the '...
Asmor's user avatar
  • 440
18 votes
4 answers
1k views

How can I design lots of different attack types that can be combined?

I'm making a top down 2D game and I want to have a lot of different attack types. I'd like to make the attacks very flexible and combine-able the way The Binding of Isaac works. Here's a list of all ...
Daniel Kaplan's user avatar
18 votes
2 answers
3k views

If "ResourceManager" classes are considered bad, what are the alternatives?

I'm hearing conflicting opinions such as: "Dedicated Manager classes are almost never the right engineering tool" "Dedicated Manager classes are (currently) the best way to survive a large project ...
Tom Dalling's user avatar
  • 1,074
18 votes
1 answer
18k views

Designing a ResourceManager class

I've decided I want to write a central ResourceManager/ResourceCache class for my hobby game engine, but am having trouble designing a caching scheme. The idea is that the ResourceManager has a soft ...
Darcy Rayner's user avatar
16 votes
6 answers
6k views

How do I correctly use singletons in C++ engine programming?

I know singletons are bad, my old game engine used a singleton 'Game' object that handles everything from holding all data to the actual game loop. Now I'm making a new one. The problem is, to draw ...
Accumulator's user avatar
16 votes
5 answers
2k views

Dictionary of common names for code objects [closed]

I'm looking for a common dictionary of terms (much like design patterns have a common language for how things interact) that are specific to games. For instance, if I'm making a game of pong with a ...
Incognito's user avatar
  • 261
16 votes
2 answers
778 views

Does game development have its own types of modeling?

In general computer science there are modeling "languages" (read: standardized diagramming techniques) such as UML 1,2, in databases there are things like ERD3, in business there are other types such ...
ConfusedStack's user avatar
16 votes
2 answers
9k views

Designing a component based game

I'm writing a shooter (like 1942, classic 2D graphics) and I'd like to use a component based approch. So far I thought about the following design: Each game element (airship, projectile, powerup, ...
Emiliano's user avatar
  • 515
15 votes
4 answers
4k views

Should a socket server and game server be separate processes?

Assume a simple standard client/server game. For the server, is it worthwhile to have a separate process that listens for connections and messages from clients and sends the data via local sockets or ...
luleksde's user avatar
  • 177
15 votes
6 answers
7k views

Game Components, Game Managers and Object Properties

I'm trying to get my head around component based entity design. My first step was to create various components that could be added to an object. For every component type i had a manager, which would ...
George Duckett's user avatar
15 votes
3 answers
4k views

Separating Game Engine from game code in similar games, with versioning

I have a finished game, that I want to decline in other versions. These would be similar games, with more or less the same kind of design, but not always, basically things might change, sometimes ...
nialna2's user avatar
  • 920
14 votes
4 answers
8k views

Is Domain Driven Design good for games?

I've just read about Domain models and it enlightened me since I've been developing a game that has a class which only holds data (few behaviors/methods). I assigned the job of handling these classes ...
Sylpheed's user avatar
  • 662
14 votes
3 answers
2k views

How do I represent projectiles in a video game?

I'm making a simple fixed shooter game, similar to "Galaga",) as part of a presentation I'm doing. I'm wondering what strategies and data structures would people use for tracking projectiles, like ...
DigitalZebra's user avatar
13 votes
2 answers
948 views

Correct way to abstract an XBox Controller

I've got a XBox360 controller which I'd like to use as input for an application. What I can't work out is the best-practice way to expose this via an interface. Behind the scenes, the class which ...
Basic's user avatar
  • 1,228
13 votes
3 answers
3k views

How to avoid singleton pattern for Event Scheduler?

I want to make an Event scheduler for my Game, I basically want to be able to schedule the triggering of a Game Event. This can be a one time trigger, or a periodic trigger (trigger event "...
Mr.Gando's user avatar
  • 575
13 votes
2 answers
2k views

How do I avoid writing Manager classes?

I seem to keep reading it's a bad idea to use XxxManager style classes in game engine programming, yet even when I try to avoid their use I always end up with ...
Ross Taylor-Turner's user avatar
13 votes
1 answer
6k views

Creating a Robust Item System

My aim is to create a modular / as generic as possible item system which could handle things like: Upgradeable Items (+6 Katana) Stat Modifiers(+15 dexterity) Item Modifiers(%X chance to do Y damage, ...
Vandarthul's user avatar
13 votes
3 answers
2k views

Design patterns for rules systems?

As a quick fun project, I tried writing a solitaire game. But when getting to writing up the rules systems, I felt dirty, because my code felt completely unstructured and inextensible, mainly because ...
Dasuraga's user avatar
  • 233
12 votes
2 answers
11k views

Making character's skills and abilities as commands, good practice?

I am designing for a game that consist of characters who have unique offensive skills and other abilities such as building, repairing, etc. Players can control multiple of such characters. I'm ...
xenon's user avatar
  • 437
12 votes
4 answers
7k views

Per-Frame Function Calls versus Event Driven Messaging in Game Design

The traditional game design, as I know it, uses polymorphism and virtual functions to update game objects states. In other words, the same set of virtual functions are called in regular(ex: per-frame) ...
11 votes
12 answers
4k views

Are there cases where globals/singletons are useful in game development? [closed]

I know that having global variables or singleton classes creates cases that can be difficult to test/manage and I have been busted in using those patterns in code but often times you gotta ship. So ...
Ólafur Waage's user avatar
11 votes
1 answer
5k views

Pattern for performing game actions

Is there a generally accepted pattern for performing various actions within a game? A way a player can perform actions and also that an AI might perform actions, such as move, attack, self-destruct, ...
Arkiliknam's user avatar
11 votes
7 answers
3k views

Separation of drawing and logic in games

I'm a developer that's just now starting to mess around with game development. I'm a .Net guy, so I've messed with XNA and am now playing around with Cocos2d for the iPhone. My question really is more ...
BFree's user avatar
  • 213
11 votes
3 answers
966 views

I want to get rid of my make-everything-static-and-global design pattern, but how?

I'm making a little dungeon crawler in space, and I'd like to hear some advice on how to make the backend of the engine nicer. Basically, currently everything is based on a crapload of managers: ...
Dlaor's user avatar
  • 377
10 votes
3 answers
4k views

What's the appropiate way to achieve composition in Godot?

How? I think I still don't properly understand how composition in Godot works. So, as far as I know, you 'compose' stuff in Godot, right? Like, if you want to make a rock you create a mesh node with ...
YoshGJ's user avatar
  • 515
10 votes
2 answers
922 views

Is it worthwhile to use particle pools in managed languages?

I was going to implement an object pool for my particle system in Java, then I found this on Wikipedia. To rephrase, it says that object pools aren't worth using in managed languages like Java and C#, ...
Gustavo Maciel's user avatar
10 votes
3 answers
3k views

Creating Entity as an aggregation

I recently asked about how to separate entities from their behaviour and the main answer linked to this article: http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/ The ultimate concept ...
Jamie Dixon's user avatar
9 votes
3 answers
1k views

Using "friend" classes in game development

Typically in C++ game development speed is valued over encapsulation, you therefore see a ton of publicly accessible class members which really shouldn't be public. I seem to find in most cases that ...
David Young's user avatar
  • 3,320
9 votes
3 answers
3k views

MVC or Components, or both?

I'm an experienced developer but recently I've been wanting to get into game programming but as you know game development is an entirely different beast from most other forms of programming (perhaps ...
JamesK89's user avatar
  • 123
9 votes
1 answer
3k views

Design of a camera system

Thinking about a common game, doesn't matter the type of the game, it's very likely that we need some camera type. For example: Debug camera: controlled by keyboard and mouse, with that we are able ...
enigma's user avatar
  • 395
9 votes
4 answers
4k views

How does an Engine like Source process entities?

On the Source engine (and it's antecessor, goldsrc, quake's) the game objects are divided in two types, world and entities. The world is the map geometry and the entities are players, particles, ...
JulioC's user avatar
  • 191
9 votes
3 answers
772 views

What pattern is this, and should I do it?

I'm making a game in as3 using flash develop and flash cs5. Everything is object oriented. I was wondering, should I have one "gateway" class that has a property-reference to all instantiations of ...
user avatar
9 votes
2 answers
3k views

How should entities in a game reference each other?

I've been reading a lot about design patterns, but in using these patterns there's one question that I keep coming back to. How should my entities access information about each other? Let's say I'm ...
Aelast's user avatar
  • 93
9 votes
3 answers
10k views

What are some ways to separate game logic from animations and the draw loop?

I have only previously made flash games, using MovieClips and such to separate out my animations from my game logic. Now I am getting into trying my hand at making a game for Android, but the game ...
TMV's user avatar
  • 183

1
2 3 4 5
7