Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

1
vote
2answers
43 views

Unity pattern for multiple game views

What are some proven and preferable patterns to realise multiple "screens" in the game? Not in the sense of displays (monitors) but "views" within the application. Say it's a Civ/Heroes-type game. We ...
1
vote
0answers
68 views

Is there an accepted architecture for these classes? [closed]

I am coding a game in python and so far so good, but I feel like my classes are not very modular. This is a simplification of what I've done: ...
3
votes
3answers
119 views

Using the Command design pattern for game AI

I'm trying to learn the Command design pattern and apply it to the game I'm working on. First I read about the general implementation, and I feel like I understand it pretty well. Now I want to know ...
0
votes
2answers
81 views
1
vote
2answers
145 views

Design pattern for turn based strategy game in C++

I'm studying computer science at university. So far I've created several programs for school projects and homeworks in C++. They were usually smaller programs up to 1000 lines of code. Now I want to ...
1
vote
2answers
97 views

Event queue: tell or ask?

I'm working my way through a lot of game development resources, coming from a completely different field of software development, I'm interested in learning what patterns are frequently used in game ...
0
votes
1answer
61 views

Item functionality with database

So the game i'm making will have items with different functionality such as ammo boxes, med-packs, guns, food, water ect. My problem is i don't know where to put the code for the specific ...
1
vote
1answer
25 views

How to organize passing data to shaders in cross-API render system?

I try to create rendering system that supports DirectX and OpenGL. I am trying to create class for constant buffer, but DirectX constant buffers and OpenGL uniform buffers have different memory ...
0
votes
0answers
25 views

Design Pattern for Firebase with Unity:

I'm implementing a game with Unity and Firebase. I'm using Authetication, Database and Analytics services from Firebase. I'm using 3 interfaces, one per service, to permit the code be independient ...
0
votes
2answers
215 views

How to implement ECS in a videogame with C++?

What do I need to know in order to implement ECS in a video game? I'm developing a video game and so far I wasn't using any complete architecture, I was just using inheritance but I don't like it ...
2
votes
2answers
57 views

Passing data to objects and sub-systems

I am currently creating a game in C++ using SDL. Many game objects and sub-systems require the use of variables such as an SDL_Renderer for drawing to the screen ...
0
votes
1answer
144 views

ECS - should everything be a system?

I've just recently started working with LibGDX and Ashley, and I find it to be really useful and I like working with the whole entity/component/system workflow. But I've been starting to layout the ...
2
votes
1answer
61 views

Encapsulating parameterised prefabs

I'm currently using the following general pattern for most of my configurable components (i.e. MonoBehaviours): ...
3
votes
2answers
165 views

How to avoid using static variables

When developing with libGDX, you can often read, that your should not use static variables if you plan to eventually release your game on android later. But while trying to follow that rule, I often ...
0
votes
2answers
48 views

How to save a global reference of an instantiated gameobject?

In my game, when I instantiate a particular prefab, I need to show a GUI window, then let player do some actions, finally close that window and update the caller ...
0
votes
0answers
55 views

Separate the graphics from game state machine

I wrote turn-based game. Game is state machine. Player can make his turn when this state machine in special state (idle) To play it player must program callback function. (This callback is called by ...
0
votes
0answers
81 views

card game backend framework

I'm doing research on how to create the server-side backend of my own web-based cardgame. I'm an experienced developer, just not in the game dev area. I'll figure out how to best communicate with ...
0
votes
1answer
119 views

How do open world games handle efficiently enemy respawn?

I'm currently working on a 2D open world game loaded in chunks, initially I thought It would be sufficient to spawn entities randomly in a specific "radius" close to the player, and periodically ...
0
votes
0answers
57 views

Separate Gizmos from Play functionality on MonoBehaviour scripts

I have a question regarding logic separation from visual debug (Gizmos) on Editor: I like to make use of Gizmos utilities to debug stuff on the Editor scene, such as waypoints and curves, such things ...
1
vote
1answer
212 views

How to design AI Manager [closed]

I am currently building a AI system for a game. I am familiar with State design pattern and implemented different states for each agent in my game. Different states are like Running, Attack, Idle, ...
0
votes
1answer
118 views

What design pattern should be used when there are a lot of different possible jobs?

Some background information on what I am trying to accomplish. I am creating the game in Unity using C#. Basically, I am trying to create an RPG type of game where it really harps on the idea of a lot ...
0
votes
2answers
37 views

Running code after after a few minutes of inactivity

I want to implement a logic that will execude after a while when no input was hapend. Like a screensaver that will get started after a few minutes of no mouse input. Im using libGDX so I think I ...
0
votes
1answer
224 views

How does an ECS work for a world subdivided into chunks (example)?

I am trying to use an ECS for my 2d game at the moment. Up until now I had my world subdivided into chunks (as minecraft does) of size 64x64. They are loaded and drawn when they come onto screen. I ...
1
vote
1answer
131 views

Are references between entities in Entitiy Component System allowed?

I've got a player entiy in my game that can pick up weapons when colliding with item entities. The player can hold and use the weapon in their hand (the weapon sprite is rendered relative to the ...
1
vote
1answer
43 views

Is a sequential update method really acceptable and is there a sane alternative?

A sequential update method is the update method pattern (e.g. as described here) where all game entities have their update methods called sequentially, even if this means the order of the entities ...
21
votes
9answers
7k 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 ...
1
vote
1answer
186 views

why does a type alias to engine specific header violate encapsulation?

In a class called Sprite.h my teacher asked this question which I don't fully understand. A generic interface has to include an engine specific header in order to expose different sprites. This ...
0
votes
1answer
210 views

Networking Board Game Design Pattern

I am currently working on a board game in Java with libgdx. It is supposed to be a multiplayer game, that you can play across multiple computers and for the sake of simplicity, I use kryonet. Even ...
1
vote
1answer
122 views

How can I make a custom memory allocation for classes with virtual methods? [closed]

I want to create a custom allocator that stores objects to the heap sequentially. The allocator itself is very simple. It just allocates a big chunk of memory and moves an offset as ...
0
votes
1answer
380 views

Tips on how to architect your JavaScript game with classes

OK, so I'm creating a <canvas> game using JavaScript (ES6+) features like Classes. It's straight from the vue-cli and <...
2
votes
1answer
53 views

Alternatives to Prototype pattern for Buildings

Hope some of you have ideas for this. first I will describe the Task ahead and then go on with the my thoughts about solving it and what kind of problems I see. 1) I have a number of buildings. ...
0
votes
2answers
195 views

Entity-Component-System design

I read a lot about ECS (strategy) pattern and have a few questions. Consider simple space game. We have stars there. Obviously star is an entity. What if I want to ...
0
votes
0answers
277 views

C# Object Cache design pattern

I'm implementing a Cache system based on objects discriminated by their enclosed Biome. To be able to make queries based on an object's type, I'm structuring the BiomeCache class as follows: ...
2
votes
1answer
79 views

Should I use attack effect collision to detect when damage is dealt? [closed]

I am wondering what a common way for actually dealing damage to different units is. Imagine a game like starcraft for example, should damage be done like this: 1) zealot attacks zergling, deal ...
0
votes
1answer
285 views

What's the proper practice to organize relationship between components in an ECS pattern?

I'm new to ECS concept and trying to refactor my app with an ECS manner. After reading some articles, I still don't get a sense about how to organize hierarchy for such pattern. My questions are Is ...
45
votes
6answers
8k views

When is the best time to consider performance?

I am coming from software development background. During the software development cycle, we only focus on functionalities and the working product. At the end of development we start optimizing the ...
1
vote
1answer
75 views

Single handler vs multiple handlers for the Command Pattern

I'll be soon implementing for the first time a Command pattern to catch general events about the world of the game I'm developing Since I haven't found much info about this particular issue, I'm ...
5
votes
1answer
344 views

Game Engine “Control Flow” Design Options?

I'm dabbling in writing my own somewhat basic game engine from scratch, and I wanted to ask about some common design configurations for connecting the various parts. I'm particularly interested in the ...
0
votes
1answer
48 views

Which Entities should be in my Pooling System?

Let's suppose that I'm designing a Tanks Battle Game, there will be a lot of projectiles and Tanks. Every Tank is composed with a Body, multiple Weapons such as Machine Guns, Missile Launchers, etc ...
1
vote
1answer
185 views

Problem with Factory Method Pattern when I try to create a Weapon:MonoBehaviour

I'm learning about Design Patterns using Unity and I'm not sure about how to solve the following problem with the Factory Method Pattern: I want to read a XML file and using the Factory Method ...
24
votes
1answer
4k 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 ...
6
votes
2answers
244 views

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

My game characters take damage by the method TakeDamage(Damage amounts), and the Damage struct has every type of damage (...
9
votes
1answer
849 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, ...
7
votes
3answers
252 views

Goal oriented Action Planning with multiple Agents

I'm a little bit stuck: I implemented an AI with GOAP (Goal oriented Action Planning, http://alumni.media.mit.edu/~jorkin/gdc2006_orkin_jeff_fear.pdf) for a simulation game. That works fine. Now I ...
1
vote
2answers
254 views

Getting Components to their respective System in Entity-Component Engine

I asked this question in stackoverflow, but I didn't get any responses. I think it's better suited in this exchange. I'm building a game engine of sorts (purely educational) and am not sure the best ...
0
votes
1answer
199 views

Observer pattern payloads

Does anyone know what Nystrom meant in this excerpt from http://gameprogrammingpatterns.com/observer.html? I created an example implementation of the observer pattern in c++ from my medal system. I ...
4
votes
1answer
550 views

How to design a Skill/Monster/Item etc. dictionary for a game?

I am trying to build a turn-based RPG where party members and enemies can cast skills and use items. How could I implement a modular list of skills/items/monsters (and maybe character classes, if I ...
-3
votes
1answer
106 views

Unity prefabs, are these common patterns? [closed]

I am developing an arcade racing game. And I'd like to know why you'd make a prefab for every car vs creating a single prefab for all cars. Here are some examples: Project 1: This project uses a main ...
1
vote
0answers
65 views

Interaction between entity and tiles

In my game, I have a player, ennemies and tiles like Mario. And each entity has a different behavior when it touches a tile. For exemple, when my player walks on spike he dies. But a certain type of ...
0
votes
0answers
75 views

How to correctly implement the command and state patterns together in Unity?

How to correctly implement the command and state pattern together in a game? ...