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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

0
votes
1answer
50 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 ...
0
votes
0answers
11 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
17 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
162 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
55 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
113 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
53 views

Encapsulating parameterised prefabs

I'm currently using the following general pattern for most of my configurable components (i.e. MonoBehaviours): ...
3
votes
2answers
139 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
45 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
46 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
56 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
84 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
40 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
207 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
116 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
35 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
188 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
109 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
165 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
177 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
102 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
279 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
164 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
260 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
78 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
191 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
72 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
297 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
47 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
180 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
243 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
660 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, ...
6
votes
2answers
197 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
225 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
185 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
490 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
102 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
63 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
63 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? ...
4
votes
1answer
95 views

How would one program potions that can change virtually every aspect of the character?

In Witcher 3, there are various potions that the character can consume. There seems to be potions that have various effects during their effect time: Restores a certain number of health points per ...
0
votes
0answers
43 views

Design convention for modular game object, Java

I want to implement a weapon object such that it would be very modular (Fallout/Borderlands like). Also assume that certain weapon extensions can cause manipulate the weapon's basic stats upon every ...
1
vote
0answers
47 views

Strategy for abstracting rendering from draw surface

This question might be a little vague because I don't know how to do this myself and I might be asking something rather silly. So here we go. Up to now, when I did my personal graphics code I used ...
0
votes
1answer
49 views

How to model classes to be serialisation friendly in c#?

It is going to be just a fraction of the code but for the sake of the example let's say I have a class Stat ...
6
votes
1answer
675 views

Is “entity component system” a principle or a pattern?

Since the ECS follows the principle Composition over Inheritance, and it makes the behavior of game objects can be changed in the runtime. If ECS is a principle, from my memory of design patterns of ...
0
votes
1answer
174 views

Three levels deep composition (player<-character<-spell), with preset character+skill sets

So I'm creating a rather generic strategy game similar to Warcraft or League of Legends, which needs to have: a Player class for representing the users playing the ...