Questions tagged [architecture]

How code is structured. For questions on the internal design of a game engine.

Filter by
Sorted by
Tagged with
185 votes
1 answer
49k views

What is the role of "systems" in a component-based entity architecture?

I've been reading a lot about entity components and systems and have thought that the idea of an entity just being an ID is quite interesting. However I don't know how this completely works with the ...
bio595's user avatar
  • 1,961
137 votes
1 answer
99k views

What should a main game loop do?

Generally, what are the core things that one should do in the game loop, and what are some things that one shouldn't do in the game loop?
52 votes
10 answers
25k views

Game State 'Stack'?

I was thinking about how to implement game states into my game. The main things I want for it are: Semi-transparent top states-being able to see through a pause menu to the game behind Something OO-I ...
PrettyPrincessKitty FS's user avatar
77 votes
11 answers
26k views

How to design a replay system

So how would I design a replay system? You may know it from certain games like Warcraft 3 or Starcraft where you can watch the game again after it has been played already. You end up with a ...
scable's user avatar
  • 821
160 votes
8 answers
56k 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
120 votes
10 answers
21k views

How does entity communication work?

I have two user cases: How would entity_A send a take-damage message to entity_B? How ...
deft_code's user avatar
  • 7,602
39 votes
3 answers
25k views

When several classes need to access the same data, where should the data be declared?

I have a basic 2D tower defense game in C++. Each map is a separate class which inherits from GameState. The map delegates the logic and drawing code to each object in the game and sets data such as ...
Juicy's user avatar
  • 581
21 votes
2 answers
22k views

Implementing a camera / viewport to a 2D game

What is the most practical way to implement camera/viewport to a 2D-game? I've read, that I should store the object world position instead of position relative to the screen? Current situation: I ...
bluekirai's user avatar
  • 313
55 votes
7 answers
9k views

How can I set up a flexible framework for handling achievements?

Specifically, what is the best way to implement an achievement system flexible enough to handle going beyond simple statistics-driven achievements such as "kill x enemies." I'm looking for something ...
lti's user avatar
  • 763
11 votes
2 answers
9k views

How to implement the interaction between engine parts?

I want to ask a question about how the information exchange between game engine parts should be implemented. The engine is separated in four parts: logic, data, UI, graphics. In the beginning I made ...
Userr's user avatar
  • 113
107 votes
11 answers
40k views

Good resources for learning about game architecture? [closed]

Are there any good resources for learning about game architectures? I am looking for high level overviews of different architectures. I tend to find information about the various pieces of a game such ...
72 votes
1 answer
38k views

Difference between Decision Trees & Behavior Trees for Game AI

What are some differences between Decision Trees and Behavior Trees for AI Game Development? For what applications would you use one over the other?
Free Lancer's user avatar
  • 1,263
20 votes
6 answers
23k views

How do I build a 2D physics engine? [closed]

The most advanced games I've made are a 8-ball pool game made with the physics engine Box2dFlashAS3 and a platform game with levels. When I did platform games, I've always wished to know how to make ...
Vishnu's user avatar
  • 1,877
20 votes
2 answers
7k views

Where should collision detection logic be placed?

I am developing a small 2D game engine. The characters have a paint method which currently does the following: Calculate the new position of the character as per its speed, etc. Update the collision ...
Cracker's user avatar
  • 497
17 votes
2 answers
13k views

Inheritance vs Composition

I make my money in C# Generally in that language I like to decouple everything to the high heavens using interfaces. This has served me well in enterprise code but in writing games in C# I find myself ...
Peter Short's user avatar
11 votes
3 answers
16k views

Synchronizing clients with a server and with each other

What is the best way for keeping all clients synchronized with a server and with each other? Currently, we have two approaches in mind: When a client sends something to the server, the server ...
Smashery's user avatar
  • 375
23 votes
3 answers
15k views

Game engine and data driven design

I've heard about data driven design and have been researching about it for a while. So, I've read several articles to get the concepts. One of the article is Data Driven Design written by Kyle ...
Amumu's user avatar
  • 333
23 votes
6 answers
8k views

What designs are there for a component based entity system that are user friendly but still flexible?

I've been interested in the component based entity system for a while, and read countless articles on it (The Insomiac games, the pretty standard Evolve Your Hierarchy, the T-Machine, Chronoclast ... ...
PrettyPrincessKitty FS's user avatar
19 votes
2 answers
6k views

How are physics or graphics components typically built in a component-oriented system?

I have spent the last 48 hours reading up on Object Component systems, and feel I am ready enough to start implementing it. I got the base Object and Component classes created, but now that I need to ...
Aidan Knight's user avatar
11 votes
5 answers
7k views

How to properly handle collision in a component-based game?

Trying to wrap my head around the ways to properly handle collision in a game designed around components. I see many examples have some sort of PhysicsComponent ...
Jason Watson's user avatar
7 votes
3 answers
8k views

Is a custom coordinate system possible in Unity

Is it possible to create a custom coordinate system (i.e the one using double for coordinates or the one dividing the world into 'chunks' of safe size) not ...
Maks Maisak's user avatar
6 votes
1 answer
455 views

LWJGL Eclipse Resource Deployment

I'm still experimenting with some OpenGL in LWJGL, and as I get to know more and more about OpenGL, I start to do more complicated things like multi texturing, shadowmapping and more. Now, right now I'...
Basaa's user avatar
  • 1,053
5 votes
6 answers
3k views

Making classes available to others

I'm currently working on a 2D game engine in XNA, and I am very interested in architecture, and how best to let my game objects communicate. I know a lot of people use a Singleton design but I ...
Jonathan Connell's user avatar
3 votes
2 answers
3k views

Using an interpolated game loop (such as Gaffer's final game loop), will the frame be rendered out of sync?

A highly recommended game loop is one from an article called Fix Your Timestep. It presents a method to update using a semi-fixed time step with interpolated rendering. The problem with this is that, ...
Dan Grower's user avatar
2 votes
3 answers
3k views

Game state sharing data

A game is a set of Game States. Each Game State contains game objects, may be list, may be scene graph or any other data structure. We can use Game States as Game Locations, too. How do you share ...
topright's user avatar
  • 1,300
70 votes
8 answers
43k views

Event-driven Communication in a Game Engine: Yes or No?

I am reading Game Coding Complete and the author recommends Event Driven communication among game objects and modules. Basically, all living game actors should communicate with the key modules (...
Bunkai.Satori's user avatar
54 votes
5 answers
13k 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
40 votes
3 answers
34k views

What is the standard C# / Windows Forms game loop?

When writing a game in C# that uses plain-old Windows Forms and some graphics API wrapper like SlimDX or OpenTK, how should the main game loop be structured? A canonical Windows Forms application has ...
user avatar
30 votes
5 answers
3k views

Doing powerups in a component-based system

I'm just starting really getting my head around component based design. I don't know what the "right" way to do this is. Here's the scenario. The player can equip a shield. The the shield ...
deft_code's user avatar
  • 7,602
30 votes
11 answers
11k views

Alternative to Game State System?

As far as I can tell, most games have some sort of "game state system" which switches between the different game states; these might be things like "Intro", "MainMenu", "CharacterSelect", "Loading", ...
Ricket's user avatar
  • 14.8k
27 votes
4 answers
3k views

What is an appropriate level of granularity for component-based architecture?

I'm working on a game with a component-based architecture. An Entity owns a set of Component instances, each of which has a set ...
Jon Purdy's user avatar
  • 800
26 votes
5 answers
20k views

How to design an AssetManager?

What is the best approach to designing an AssestManager that will hold references to graphics, sounds, etc. of a game? Should these assets be stored in a key/value Map pair? I.e. I ask for "...
Bryan Denny's user avatar
  • 5,103
22 votes
1 answer
7k views

How should I structure an extensible asset loading system?

For a hobby game engine in Java, I want to code a simple but flexible asset/resource manager. Assets are sounds, images, animation, models, textures, et cetera. After a few hours of browsing and some ...
user8363's user avatar
  • 600
21 votes
4 answers
7k views

How to implement behavior in a component-based game architecture?

I am starting to implement player and enemy AI in a game, but I am confused about how to best implement this in a component-based game architecture. Say I have a following player character that can ...
ghost's user avatar
  • 1,529
21 votes
13 answers
65k views

How do I ensure a piece of code runs only once?

I have some code that I only want to run once, even though the circumstances that trigger that code could happen multiple times. For example, when the user clicks the mouse, I want to click the thing:...
House's user avatar
  • 73.2k
20 votes
2 answers
3k views

Component-Based System online resources [closed]

I've been considering moving to a more component-based approach in my games. Does anyone else have any decent reference material or sample implementations that would help make this transition a little ...
20 votes
4 answers
3k views

Calculating the output of two armies fighting

I am programming a strategic game using Flash. The game works very similar to the famous game "Travian". My problem is as follows: I am trying to make the calculation of the troops lost as a result ...
Ali Albahrani's user avatar
20 votes
4 answers
7k views

Alternatives to Singletons / globals

I've heard countless times about the pitfalls of Singletons / globals, and I understand why they're so often frowned upon. What I don't understand is what the elegant, non-messy alternative is. It ...
vargonian's user avatar
  • 829
15 votes
6 answers
6k 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
12 votes
5 answers
14k views

Keyboard input system handling

Note: I have to poll, rather than do callbacks because of API limitations (SFML). I also apologize for the lack of a 'decent' title. I think I have two questions here; how to register the input I'm ...
PrettyPrincessKitty FS's user avatar
10 votes
2 answers
20k views

Should I use an SQL database to store data in a desktop game? [closed]

Developing a Game Engine I am planning a computer game and its engine. There will be a 3 dimensional world with first person view and it will be single player for now. The programming language is C++ ...
danijar's user avatar
  • 5,731
4 votes
1 answer
1k views

How to synchronise the acceleration, velocity and position of the monsters on the server with the players?

I'm building an MMO using Node.js, and there are monsters roaming around. I can make them move around on the server using vector variables acceleration, velocity and position. acceleration = ...
Nick's user avatar
  • 1,605
3 votes
1 answer
1k views

How should my game characters store their abilities/spells?

I'm new to game development and a bit confused about how to effectively store an object's access to certain spells/abilities. The player and mob objects are all generated from the same class. However,...
Vecta's user avatar
  • 147
1 vote
1 answer
1k views

Multithreading: Each system on a different thread or a thread pool?

I'm building a fairly involved game using OpenGL and C++. I've been thinking about how to implement multithreading, and the two options are: 1) Each system (Graphics, Audio, Physics, et cetera) gets ...
Rish's user avatar
  • 181
33 votes
7 answers
3k views

Elegant way to simulate large amounts of entities within a game world

Assume you have a game in which there are many (many many) entities serving some functions, not all of which are constantly needed or need to be considered in every frame. The concrete problem I am ...
Marc Müller's user avatar
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
22 votes
4 answers
19k views

Resource Managers - Are they any good?

I've seen many a time in source code, things like this [well, this is more of a pseudo C++ idea of mine] ...
PrettyPrincessKitty FS's user avatar
22 votes
4 answers
4k views

Architecture a for a central renderer rather than self-rendering [duplicate]

For the architectural side of rendering, there's two main ways: having each object render itself, and having a single renderer which renders everything. I'm currently aiming for the second idea, for ...
PrettyPrincessKitty FS's user avatar
19 votes
3 answers
3k views

How to create a Ghost Replay feature in a game?

When you set a personal best lap time in a console racing game, you have the option to compete against your ghost. How can this feature be created for a single player casual type game?
claude keller's user avatar
18 votes
1 answer
13k views

How to apply Data Oriented Design with Object Oriented Programming? [closed]

I've read lots of articles about Data Oriented Design (DOD) and I understand it but I can't design an Object Oriented Programming (OOP) system with DOD in mind, I think my OOP education is blocking me....
Pombal's user avatar
  • 829