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
1
vote
1answer
29 views

How to control JavaFX's animations execution order when animations “queue” is being altered in run-time?

What is the proper way of handling synchronization between GUI animations' execution order and the user's dynamic input? More specifically, I would like to know how to enforce some logical ...
0
votes
1answer
62 views

Possible patterns for Registering event listeners of game entities with an event queue

I'm trying to integrate the idea of an event queue with a game loop that creates entities and responds to input. Is it better practice to submit entity reaction functions to the queue during input ...
0
votes
0answers
41 views

Using State Pattern with Unity

I am new to Game Development and Unity. I have written a component for Jumping and Running, CharacterJumpAbility.cs and CharacterRunAbility.cs. I would like the Character to be able to Jump only if ...
0
votes
1answer
64 views

Handle states in character in functional programming way

How to handle any change of state of a character with functional programming? If I'm using functional programming the character should be stateless, in my understanding. With that said, I should ...
1
vote
1answer
86 views

What's the generally accepted way to coordinate game events between objects?

I'm a newbie when it comes to game development and I'm struggling to decide on a good and consistent architecture for having child game objects trigger actions at a higher parent level. For instance, ...
1
vote
2answers
160 views

What strategies and patterns exist to handle large amounts of game entities?

I've been wondering this for some time now: Let's say you have a builder game like Anno and let's say you're in the very late game. You have literally thousands of production facilities placed. Each ...
1
vote
1answer
60 views

Can I have a scene graph translation node with multiple parent nodes?

I am trying to write a C++ scene graph structure. While designing the node classes I am facing the below issue. I have a scene graph to represent a house. I would like to have another house next to ...
0
votes
3answers
271 views

How to build a better game save?

I am making a roguelike card game like dream quest, and I want to improve my dungeon/level save method. Here's what my levels look like: I checked dream quest saves but I don't like their method ...
1
vote
2answers
77 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
82 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
285 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
92 views

Replacing harcoded strings used internally to locate stuff

The fields: (example) ...
1
vote
2answers
751 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
237 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
78 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
60 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
2answers
432 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
66 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
370 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
72 views

Encapsulating parameterised prefabs

I'm currently using the following general pattern for most of my configurable components (i.e. MonoBehaviours): ...
3
votes
2answers
331 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
77 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
1answer
224 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 ...
1
vote
1answer
220 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
122 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
54 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
371 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
295 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
53 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
272 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
294 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
323 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
798 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
58 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
296 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 ...
2
votes
1answer
93 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 ...
1
vote
1answer
512 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 usually focus on functionalities and the working product. At the end of development, we start optimizing ...
1
vote
1answer
107 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 ...
4
votes
1answer
548 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
50 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
214 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 ...
25
votes
1answer
5k 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 (...
10
votes
1answer
2k 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, ...
8
votes
4answers
704 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
322 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
283 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 ...
3
votes
1answer
774 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 ...