89 votes
Accepted

When is the best time to consider performance?

Engineering for Performance Follow vendor recommendations. Use the correct data structures. Implement the correct usage patterns. Don't do anything stupid. Optimization When already written code is ...
user avatar
65 votes
Accepted

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

It depends, but usually I use a third method. The problem with the methods that you used is that in the event that the object is included to begin with, it will not remove them from the tree, and they ...
user avatar
43 votes

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

Here's a quick summary: ...
user avatar
  • 112k
41 votes
Accepted

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

If you're planning to instantiate many instances of the same prefab, you should definitely think about using object pooling. Calling Unity's Instantiate function is one of the most taxing method calls ...
user avatar
  • 508
32 votes

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

The best implementation of a generic Singleton pattern for Unity I know of is (of course) my own. It can do everything, and it does so neatly and efficiently: <...
user avatar
  • 2,034
31 votes

How to create a user-friendly magic spell system?

There's no "best" way. The game design in your case is intimately connected with the UI design. However, given your setup, I'll lay out (haha get it) some advice. You're right about the lower-level ...
user avatar
  • 6,399
27 votes
Accepted

Command Ordering Architecture of Dwarf Fortress

At first you see that your commands are in the form of a list, so your first instinct might be to recreate that structure, and each dwarf will run through that list in sequence. What I suggest though ...
user avatar
  • 14.5k
23 votes

How to create a user-friendly magic spell system?

Almo's advise to allow the player to assign spells to hotkeys according to their own preference is good. You can increase the number of spell slots if you allow modifier keys like Ctrl and Shift to ...
user avatar
  • 111k
22 votes
Accepted

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

As with everything in software development, there is no ideal solution. Only the solution which is ideal for you and your project. Here are some you could use. Option 1: The procedural model The ...
user avatar
  • 111k
22 votes

When is the best time to consider performance?

If you want to do optimization at the right times, have slow machines and use them. For a small shop, a good option is to use a slow laptop on the commute and a fast desktop in the office. As an ...
user avatar
  • 9,927
17 votes
Accepted

Should a socket server and game server be separate processes?

From an API design perspective, when deciding whether to make multiple separate communicating programs or just one, the question is: can each program function meaningfully without the others? The ...
user avatar
  • 13.3k
13 votes
Accepted

User vs Player Model

They're typically not even handled by the same machine, much less the same codebase. The user profile is handing by a service that deals only with users. The simulation server deals with in-game ...
user avatar
13 votes

What do I need to consider before making any class singleton?

Do you think you don't need more than one or do you think there must never be more than one? The singleton pattern is mostly useful in situations where the existence of more than one instance of a ...
user avatar
  • 111k
12 votes

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

Create an engine module/folder/whatever, that contains everything that can be generalized and is 100% independent from the rest of the game. This would include some code, but also generic assets ...
user avatar
  • 29.1k
11 votes

Should a socket server and game server be separate processes?

is it worthwhile to have a separate process that listens for connections and messages from clients and sends the data via local sockets or stdin to another process that runs the actual game server? ...
user avatar
  • 319
11 votes

Command Ordering Architecture of Dwarf Fortress

If you can make sequences pretty general, there's not much of a spaghetti code. In case of deliveries e.g.: WorkTask operates with a WorkPlan. Workplan says what kind of resource unit must pick, from ...
user avatar
  • 10k
10 votes

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

So, Mike Hunt, your question so interested me, I decided to implement a full solution. After three hours of trying different things, I ended up with this step-by-step solution: (Please note, that ...
user avatar
  • 655
10 votes

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

I'd just like to add that it may be useful to call DontDestroyOnLoad if you want your singleton to persist across scenes. ...
user avatar
  • 531
10 votes
Accepted

Understanding Entity Component System

Can Component hold the logic? or it should not and stay as a bag of data? That's how you like. I suggest to stick with the first implementation and finish your project, then see if it worked out ...
user avatar
  • 15.3k
9 votes

When is the best time to consider performance?

No, you don't have to check after every line because not every line is performance-relevant. It mostly depends on how often a line is executed. A code section which takes 1 ms to be executed is ...
user avatar
  • 111k
9 votes

How to create a user-friendly magic spell system?

In addition to the old classic, coming from fighter games - key combos. The better the spell, the longer the combo. This has the added benefit of feeling like casting, and a high level spell actually ...
user avatar
  • 191
8 votes

Is Domain Driven Design good for games?

Paradigm As of the time that this answer was written, the other posted answers here are all wrong. Instead of asking whether or not Domain-Driven Design is good for games. You should ask whether or ...
user avatar
8 votes
Accepted

Creating a Robust Item System

I think you can achieve what you want in terms of scalability and maintainability by using an Entity-Component System with basic inheritance and a messaging system. Of course, have in mind that this ...
user avatar
8 votes

Should I store a value for every damage type even if zero, when using the Decorator pattern?

As a general rule, one should never be a slave to any pattern. Be flexible. As for the particular example you give, it's a rather well known case, so I can help a bit with the pros and cons. I can ...
user avatar
  • 1,197
7 votes

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

I'm writing this at a time when the accepted answer is by a contributor who strongly opposes the concept and I wish to provide a different view: Dependency injection is indeed not widely used in game ...
user avatar
  • 202
7 votes

Does game development have its own types of modeling?

One of the actual models that I know about in game design is the MDA framework. This is the closest thing to your question that I can think of, as MDA gives you a reference to think and talk in (thus ...
user avatar
7 votes
Accepted

Decoupling AI from game logic

A design pattern I've enjoyed using has two types of things: task management and task execution. Task management asks the question "What should I be doing right now?" And task execution asks, "How do ...
user avatar
  • 3,567

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