Skip to main content

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
0 votes
0 answers
34 views

Command Pattern or/and Event Handling porgramming paradigm?

I have created a dynamic library that contains all the tools I want my game executable to have. Additionally, I want to create a world editor/tools for my engine to be more user-friendly. I'm ...
0 votes
0 answers
55 views

SDL2 Events how to avoid monolithic control statement?

I'm using SDL2 in my game engine and I'm trying to figure out how I can prevent having a monolithic control statement like this: ...
0 votes
1 answer
85 views

Singletons as presented in Game Engine Architecture by Jason Gregory

I am reading the amazing Game Engine Architecture 3rd edition by Jason Gregory, but I have trouble understanding the singleton part, more particularly the part dealing with subsystem start/shutdown... ...
1 vote
3 answers
103 views

Unity Game Architecture

I'm working on a relatively simple game, but even simple games have a lot of moving parts, and I'm running into some architecture issues. Just to be clear, everything works fine, but it feels dirty, ...
0 votes
2 answers
621 views

What’s the benefit of breaking code down into other classes? [closed]

Sorry if this isn’t the proper spot to ask, but something I struggle to wrap my head around is the benefit of breaking down code into smaller pieces on the surface it seems to make sense I think you ...
2 votes
1 answer
85 views

Skill Class design : How to deal with multiple criteria

I'm planning to make a Class for RPG game's character skill. But the problem is that the skills need to be classified by multiple criteria. Below are the criteria for skills. Independent / dependent ...
2 votes
1 answer
362 views

What design pattern should I use for adding functionality

I am making a tile based roguelike game with different objects in the world, like Doors, Security Cameras, Storage Shelves. With that, there are objects that have an inventory, can detect the player, ...
0 votes
0 answers
28 views

Workaround to bind templated functions to lua?

I'm trying to add Lua for scripting to my C++ game engine, which is based on ECS, and I have a rough idea of what I want to do (is it good? probably not) but trying to actually execute it has been ...
0 votes
0 answers
102 views

How to implement events with ECS?

I'm transitioning over to an ECS architecture for a small C++ graphics engine I'm working on and I'm a bit stumped on how to tackle events. One solution I came across was from this Reddit post ...
1 vote
1 answer
122 views

What is a "controller"?

I'm in the process of refactoring my camera code the goal is to try and simplify things using a struct instead of a class or at the very least try something new since I always jump straight to classes/...
0 votes
2 answers
95 views

What happens with global/singleton objects when using ECS?

As I've been learning about ECS one thing that gets me confused are things like input which in my case has usually been some singleton that gets polled or in one project was event based where code can ...
1 vote
0 answers
114 views

Good practices for making a manager class?

I found this post for designing a camera system the post mentions having a manager where you could register and set different cameras such as debug, player, script, etc and I kind of like this ...
0 votes
0 answers
61 views

Architecture and design patterns for components

I was working on a physics-based plug-in/ extension for Unity water which would essentially be another component in Unity water. The goal of this extension would be to integrate interactive physics ...
1 vote
0 answers
48 views

How could I build components for a composable loot system like one in RuneScape without using OOP?

I looked at some entity component systems, and noticed that they sometimes list static polymorphism as a feature, and ECSs and data oriented programming seem to be touted as holy grail of modern game ...
0 votes
1 answer
95 views

Implement Singleton that loads before Awake

I would have liked to comment on this answer, but I don't have enough reputation so I had to open this new one. The issue with it (and with the rest of the answers) is that it doesn't work well if ...
3 votes
2 answers
2k views

In an object-oriented game engine, should there be seperate classes for objects with and without parents?

I am developing a game engine in C++ (for an idea of what kind of design I'm going for, think of ROBLOX, if you're familiar with that) and I need help with a problem I have. So basically, the objects ...
1 vote
0 answers
268 views

Why does ROBLOX use an object-oriented system rather than an entity component system? [closed]

I decided I would develop a game engine in c++, so I was thinking about different ways of handling objects. I also have experience with ROBLOX, so I know that it uses an object-oriented design as ...
10 votes
3 answers
4k views

What's the appropiate way to achieve composition in Godot?

How? I think I still don't properly understand how composition in Godot works. So, as far as I know, you 'compose' stuff in Godot, right? Like, if you want to make a rock you create a mesh node with ...
2 votes
3 answers
545 views

Is there some psychological reason for why most game's UI is always the same colors?

Shooter games : Either Blue/teal/azure or other shades of blue and transparent or gray and transparent MMO games : Either blue and transparent or shades of Brown+Gold or a very dark red, so dark it's ...
0 votes
2 answers
208 views

How to implement diminishing returns for multiplicative character stats?

I'm very bad at math, ridiculously so. I'm making attributes that work as multipliers. 1 Agility means : animation speed * agility, ...
1 vote
2 answers
281 views

Design patterns for non-modal (in-game) dialogues/cutscenes in a game engine

I want to create a scripted dialogues/sequences between NPCs and/or PC during the game. I have a DSL to configure a PC's dialogue with one NPC, inspired by Inkle and Twine. Now, I need a dialogue ...
1 vote
1 answer
64 views

Designing a system for delivery

I'm writing a game where deliveries are made to specific people. These people act in different ways depending on what the delivery is. At times one character might ask the player to make a delivery to ...
0 votes
0 answers
130 views

Good design for player input handling in 2d game

I am working on a java 2d game. Keeping things short, I'd like to improve my current input handling. Basically the player can move up/down/left/right with WASD, perform an attack with mouse left click ...
1 vote
0 answers
192 views

Am I doing something wrong in my ECS architecture if I must choose between coupling or copying code?

I'm developing a somewhat simple, small roguelike game as my university project. Early into development I heard about Enity-Component-System and decided to go with that as my game's architecture. ...
2 votes
1 answer
380 views

Best way to extend Unity Rigidbody?

I am designing a physics class library for Unity and would love to be able to hook and inject functionality into Unity's Rigidbody class, but it's my understanding ...
20 votes
2 answers
3k views

Development pattern for interactive in-game tutorials

Interactive in-game tutorials often interrupt game flow and override standard behavior in a way that can be difficult to implement cleanly. For example, imagine we have an action game and we want a ...
12 votes
2 answers
11k views

Making character's skills and abilities as commands, good practice?

I am designing for a game that consist of characters who have unique offensive skills and other abilities such as building, repairing, etc. Players can control multiple of such characters. I'm ...
2 votes
1 answer
324 views

NullReference exception with a singleton input manager

I've been using the new input system to simulate touch in my game, it works perfectly but only with the input manager(which is a singleton for the ease of use), when I add the PlayerMover script it ...
20 votes
3 answers
8k views

Design of a turn-based game where actions have side-effects

I am writing a computer version of the game Dominion. It is a turn-based card game where action cards, treasure cards, and victory point cards are accumulated into a player's personal deck. I have the ...
0 votes
0 answers
73 views

What class should access my database?

I would like to code a turn-based RPG, and I decided to use a database to store all skills in the game. Now I have to decide as well which class can see this database, and how classes pass around ...
79 votes
10 answers
235k views

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

I have seen several videos and tutorials for creating singleton objects in Unity, mainly for a GameManager, that appear to use different approaches to instantiating ...
2 votes
2 answers
752 views

How to handle "identity" of unit/building types within an RTS context?

TL; DR: How do I give unit and building types a unique "identity" without turning my codebase into a mess? I've been reading the genius Game Programing Patterns and it's made me very (...
4 votes
1 answer
167 views

Encapsulating parameterised prefabs

I'm currently using the following general pattern for most of my configurable components (i.e. MonoBehaviours): ...
1 vote
1 answer
91 views

How do I solve a problem where sometimes recursion is untenably vast and sometimes it is not?

I am writing a programming language of my own. (I've done two Turing complete ones in the past, but this time I'm trying to actually be useful.) Now, one thing that should be especially easy with ...
2 votes
1 answer
235 views

How to handle duplicate logic in a state machine for a platformer player?

I'm trying to implement a platformer character using a finite state machine, but I have troubles understanding what kind of logic goes into a state and what logic goes into a main player class ...
1 vote
1 answer
519 views

Implementing ability system with ability parameters

I am trying to implement an ability system in Unity for a game similar to XCOM (turn based, team consists multiple of units, grid based). Every unit have X action points per turn. I would like to do ...
0 votes
1 answer
81 views

Using a state pattern across multiple controllers / general architecture advice

I'm trying to implement a state pattern - having skated by with enums forever - and have hit a bit of a wall when it comes to it's implementation in my game. It's a grid based strategy game with an ...
2 votes
2 answers
388 views

how to structure game logic for user interfaces of different nature (gui, tui, cli)?

I would like to implement a simple game logic engine that is agnostic to the rendering system, but I don't know how to do that, really... so I would like to have advise and know the state of the art! ...
0 votes
1 answer
653 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
2 answers
1k 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 ...
0 votes
2 answers
591 views

What is a pattern to manage execution order of C# delegates in Unity

Note: I have two Managers: First one creates 2d block upon click. The other one, upon click, grabs a block for dragging. The reason I need them to run in specific order is because newly created block ...
0 votes
1 answer
94 views

How to design a system that allows for custom equations of movement?

I'm developing a top-down shooter and I currently have a PhysicsSystem which operates on TransformComponents. Basically, it ...
2 votes
1 answer
2k views

What should be an entity/component, and what shouldn't?

I've recently been reading the book Game Programming Patterns by Bob Nystrom, and one chapter I've found a bit hard to grip is the chapter about the Component pattern. In the example he uses (which ...
0 votes
1 answer
85 views

Singleton issue [closed]

I have two scenes, The first one called "Boot" contains and ObjectPoller class that instantiates all GameObject in the game and disable them. I made it a singleton with "don't ...
23 votes
2 answers
10k views

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

I'm looking for a solution for a "Right Click Options" behaviour. Basically any and every item in a game, when right clicked, can display a set of options based on whatever the object is. Right ...
2 votes
1 answer
564 views

Is it better design to store event effects within an Entity itself, or within a system?

I'm developing a 2D roguelike with an Entity Component System (ECS) and I've been struggling with this question a lot the past week. For example, let's say you have various effects that occur when an ...
4 votes
0 answers
127 views

How to map interaction events to game actions

When I port between Desktop games and Mobile games, I find I always make a kludge out of the interaction events. I typically end up hard-coding event handling for mobile, and event handling for the ...
4 votes
1 answer
2k views

2d map: how to manage it?

i'm developing a 2d game (top down), and i'm a beginner. Now, i've to create a map, with object (to interact with) ... I don't know how to .. manage the problem ! Does anyone can help me ? What are ...
2 votes
1 answer
172 views

Scaling physics engines beyond single computational server

Currently working on a small home project of developing our own game. The game basics are just a straightforward space game, currently without any collision detection/resolution, just movement with ...
0 votes
1 answer
268 views

How to decide whether a Buff should be a component or a Buff object in an ECS?

I'm developing a top-down 2D game in Javascript using an Entity-Component-System architecture and I'm struggling with the question of exactly how to implement temporary buffs / permanent passives. For ...

1
2 3 4 5
7