The polymorphism tag has no usage guidance.
1
vote
1answer
72 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 Header:
struct EntityType
{
public:
...
2
votes
2answers
184 views
Cost of Using Virtual Methods to Query Properties?
Let's say you're making a tile-based roll-playing game, and you're obsessed with OOP.
You have an abstract base class Tile which will be inherited from by many derived classes, like Grass Sand and ...
1
vote
1answer
82 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
1answer
149 views
'Ball.rigidbody' hides inherited member 'Component.Rigidbody'
I have some understanding of c# and I am new to unity. I am currently making a 3D project which use the Rigidbody component on the ball object.
When I use following code:
public class Ball : ...
2
votes
1answer
630 views
Unity polymorphism in editor through a list
So I have an ItemDatabase class which basically only has a list of Item
public class ItemDatabase : MonoBehaviour {
public List<Item> Items = new List<Item>();
}
The Item class looks ...
6
votes
1answer
3k views
Unity3D [C#]: How do I use a custom inspector to expose an array of polymorphic objects to edit?
[EDIT: based on some feedback, I pruned the example down to the base functionality of the bug we are trying to solve. The description below remains accurate, but the repro has been shortened to:
Add ...
3
votes
1answer
490 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 ...
0
votes
1answer
90 views
Interface or Class Inheritance [closed]
I am making an inventory system. Different inventory item will have different uses so i am thinking about making a base class called InventoryItem and derive Wood, Gold, Weapons and so on. This way ...
9
votes
3answers
590 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 ...
5
votes
4answers
1k views
Inheritance Hierarchy and Design — avoiding multiple inheritance
I am working on a 3D game, and need some advice about how to best design and structure my code so that I achieve what I'm going for without using bad practices like multiple inheritance.
Basically ...
0
votes
1answer
1k 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'...
0
votes
1answer
409 views
Problem creating levels using inherited classes/polymorphism
I'm trying to write my level classes by having a base class that each level class inherits from...The base class uses pure virtual functions.
My base class is only going to be used as a vector that'...
2
votes
2answers
130 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 attacker through an array of waypoints as given below:
- (void) update:(ccTime)dt {
if(state == kMove) {
...
-7
votes
2answers
726 views
Component-based entities without IDs?
I'd like to know if someone has found a way to build a component-based entity system in their game(s) without using IDs. I find that IDs tend to do away with one of the major (possible) advantages of ...