Questions tagged [polymorphism]
The polymorphism tag has no summary.
26 questions
0
votes
1
answer
120
views
Newtonsoft.Json JsonConvert.DeserializeObject (Polymorphism)
I'm using JsonConvert.DeserializeObject to deserialize animals from the Animal list, but unfortunately they get deserialized as Animals instead of their derived classes (Cat and Dog). As you can see, ...
0
votes
0
answers
90
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
1
answer
87
views
Problem with Parameters for polymorphism class
This is going to be a bit tricky but it is really bothering me so I hope you will have the patience to follow along :)
Here is my very basic architecture:
So in the framework, I am creating I have <...
0
votes
0
answers
180
views
Remove nested if statements
I have been learning a new method of programming. I have been programming many years and am recently finding out there is a better method in general via abstract classes.
My question is how to ...
1
vote
1
answer
1k
views
RPG Item Design [duplicate]
I'm currently fiddling around with some RPG mechanics and I'm trying to implement a solid way to handle items that have different on use effects.
Currently, I have a base class called "Item" that ...
0
votes
2
answers
276
views
How to: Duplicating and updating component data in systems
I am new to game development. Coming across the ECS (entity-component system) pattern I generally quite liked the idea. I have implemented the current version of my engine using the OOP style approach....
1
vote
1
answer
476
views
Component based Entity System using polymorphism: OpenGL does not render
I want to be able to create Entities from different Component sets. I want to call Entity entity(new StaticObject(modelpath, position));
I have an EntityTypes ...
1
vote
1
answer
478
views
Inherited property in derived class reference only base class
[Context] I am developing a game in Unity, and wanted to make a Game Manager. Like many examples out there, it uses a Singletron design pattern. But i have several other Managers, all using Singletron ...
2
votes
1
answer
3k
views
Unity polymorphism in editor through a list
So I have an ItemDatabase class which basically only has a list of Item
...
3
votes
1
answer
1k
views
Collision Shapes Abstraction Design
Straight to the facts.
I have a base CEntity class for different entities in my game:
Static entities ( those do not move, simply props and items )
Dynamic entities ( these move, jump )
Each of these ...
9
votes
3
answers
1k
views
Flexible alternatives to many many small polymorphic classes (for use as properties or messages or events) C++
There are two classes in my game that are really useful, but slowly becoming a pain. Message and Property (property is essentially a component).
They both derive from a base class and contain a ...
1
vote
1
answer
2k
views
Creating an abstract Animation class
I'm creating a simple 2d game with c++ and SFML, and I've got a simple framework going for animating a sprite using a "SpriteSheet" image (an big image containing all the "frames" of an animation)
I'...
2
votes
2
answers
203
views
How to handle similar actions in derived actors (inheritance)
I have a base class called Attacker that has a update method. The update method moves ...