Questions tagged [oop]
Object-oriented programming. A paradigm using objects (instances of a class consisting of properties and methods) to design games. Techniques may include data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance.
127 questions
0
votes
0
answers
71
views
Best way to structure code for a character dependent on its environment and vice versa
What is the neatest way in a strict OOP language (c++ say) to avoid the following circular dependency. Imagine I create a character class and a world class. A character requests data from the world to ...
0
votes
0
answers
89
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 ...
1
vote
0
answers
144
views
When to use the same class for both client and server versions of an object, vs. when they should differ
I am learning about networking for game development and need some insight.
My knowledge of Unreal Engine is that it uses RPCs and replicated variables for actors. I also know that Unity has Networked ...
0
votes
0
answers
89
views
How to handle collision detection with different 2D shapes while maintaining performance? Is polymorphism appropriate?
If I'm making a small library for handling 2D shapes, should polymorphism generally be avoided? I know that it can worsen performance but it's not like polymorphism is never used in game development ...
0
votes
2
answers
114
views
Modeling a naturally circular relationship between three classes
I have three classes Location, Item, Character.
Every ...
1
vote
1
answer
406
views
How to include cross cutting concerns like sound/graphics effects in an ECS?
It does not seem like a good idea to include this functionality in the game logic like that even if the concrete implementation of the sound or graphics effect is abstracted away. Ideally, the game ...
0
votes
1
answer
113
views
SFML: Object's shape not rendered on the window [closed]
I want to be able to render sf::CircleShape (representing pointwise charges) when pressing mouse buttons on the window. The problem is easy enough, however the ...
0
votes
1
answer
200
views
Pygame bullet firerate not working sometimes
i have made this bullet class but i have a problem with the firerate. Sometimes i'm not able to shoot even when the little delay (700ms) between the two shots has ended. I guess it's due to the ...
0
votes
1
answer
87
views
How do I get my fish to face the right way?
I'm making this 2d collecting game in Unity where you collect fish. However I can't get them to face the direction they are going. I've asked on some Discords and got no answer. Thanks in advance.
...
0
votes
2
answers
693
views
Should a game object class contain the information for how to render it?
If I have a class called Enemy:
// Simplified version
class Enemy
{
float xPosition_;
float yPosition_;
int hp_;
};
Should this class also contain the ...
0
votes
0
answers
92
views
is there any different solution for different buildings different behaviours
I'm trying to make different behaviours for workers of different buildings, let's say an agricultural worker would need to sow wheat seed and collect the wheat grain when it's grown. let's call that <...
2
votes
0
answers
171
views
How can an Entity trigger changes to the world in C++?
I'm writing a simple physics based game in C++ using SFML. I want to trigger a scene change when my playerCharacter collides with a door. Since C++ does not have any native Event Sender/Listener ...
0
votes
1
answer
105
views
Best way to implement a class or interface for a set of UI buttons that only differ in their Draw() function?
I have three types of UI buttons that go on a cooldown bar:
A traditional cooldown bar button where once the corresponding key is pressed, a timer shows over the button and dims the texture.
A button ...
0
votes
0
answers
53
views
Efficient system to reach the "parent" variable
I've been stuck doing this in a very inefficient way and really want to know if there's some design pattern that solves this because it seems like a pretty common problem to have.
I have a system ...
1
vote
0
answers
649
views
What design pattern would be most suitable for RPG skills?
I'm developing a small Java digital card game project. In my game, players can perform skills when using cards. Each skill does different things, like deal damage, heal etc.. I'm looking for a way to ...
0
votes
1
answer
2k
views
How to pass renderer through classes?
I am making a game with SDL and C++. I am trying to render simple image to the screen but I can't. I am not getting any error but I see only black screen.
I think because the renderer in ...
2
votes
2
answers
4k
views
How to update the value of all owners of shared_ptr?
I’m writing a render, there is a class that shaders should store, something like a shader manager. These shaders are stored as
...
0
votes
2
answers
106
views
How to modularly call a script based on parameters within the script?
I am coding an interaction system in Unity that does things based on whether the player taps interaction, or holds interaction. Each object holds their own scripts of how a player can interact with ...
2
votes
1
answer
164
views
Passing a value to a stuct
So I've been making a 2D grid and pathfinder using SFML. Now I ran into a problem. I've been making a vector for the path nodes.
...
0
votes
1
answer
2k
views
Read access violation, pointer was nullprt
Im trying to figure out how to use pointers to make a single instance of an object that in this example will just change direction on x-axis.
Splav.h (eng. Paddle.h)
...
38
votes
8
answers
19k
views
Should I avoid using object inheritance as possible to develop a game?
I prefer OOP features when developing games with Unity. I usually create a base class (mostly abstracted) and use object inheritance to share the same functionality to the various other objects.
...
0
votes
1
answer
2k
views
Unity Custom EventManager, multiple arguments, and order
I have some hard question for me...
I have a nice EventManager, who handle multiple arguments. (no argument, one int, one bool, a GameObject and a bool... but for each sort, I have to create a special ...
1
vote
1
answer
431
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 ...
1
vote
1
answer
1k
views
Detecting Overlapping Shapes
I have two classes Circle and Square which derive from an abstract base class Shape.
A <...
1
vote
0
answers
50
views
Javascript: world tile generator bug? collision not working, player falls down? [closed]
Hi I have a serious problem here, When I generate my tile map from an array with numbers [0,4, ...] (0 > for air, 4 for solid) inside of generateWorld()... the ...