Skip to main content

Questions tagged [polymorphism]

Filter by
Sorted by
Tagged with
0 votes
1 answer
120 views

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, ...
Manuel Saraiva's user avatar
2 votes
1 answer
455 views

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, ...
RobinHood's user avatar
0 votes
0 answers
92 views

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 ...
JensB's user avatar
  • 157
0 votes
2 answers
289 views

For a long time Robert Martin has been advising against if/else/switch branching logic and instead rely on the polymorphic behavior of different types. ...
Ken's user avatar
  • 6,136
0 votes
1 answer
87 views

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 <...
Marc Rasmussen's user avatar
0 votes
0 answers
92 views

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 <...
MilitaryG's user avatar
0 votes
0 answers
180 views

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 ...
user2455808's user avatar
0 votes
1 answer
156 views

I want to implement a damage system that works across both living items (Entity) and environment items (Environment). The key ...
Kendall's user avatar
  • 107
1 vote
1 answer
1k views

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 ...
Grant Upson's user avatar
3 votes
2 answers
1k views

I've been planning out an Entity-Component System in C++. My idea of it is most in line with the one described on this page of the entity systems wiki. To summarize, components are just structs of ...
DragonOfAwesome's user avatar
0 votes
2 answers
277 views

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....
Adrian Albert Koch's user avatar
0 votes
1 answer
1k views

I have implemented an entity component sytsem (ECS) in my game engine (SFML and C++ 17). An entity has an array of components. You can get a components by its type e.g.: ...
Adrian Albert Koch's user avatar
1 vote
1 answer
478 views

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 ...
simulate's user avatar
  • 145
2 votes
2 answers
273 views

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 ...
Willy Goat's user avatar
  • 1,038
1 vote
1 answer
481 views

[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 ...
Romulo Rocha's user avatar
3 votes
1 answer
1k views

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: ...
Pawel's user avatar
  • 133
2 votes
1 answer
3k views

So I have an ItemDatabase class which basically only has a list of Item ...
Tikkes's user avatar
  • 173
6 votes
1 answer
6k views

[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 ...
Mike Gonzales's user avatar
3 votes
1 answer
1k views

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 ...
cdmstr's user avatar
  • 55
0 votes
1 answer
144 views

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 ...
Daarwin's user avatar
  • 829
9 votes
3 answers
1k views

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 ...
Bryan's user avatar
  • 235
5 votes
4 answers
3k views

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 ...
MVTC's user avatar
  • 239
1 vote
1 answer
2k views

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'...
loogie's user avatar
  • 13
0 votes
1 answer
654 views

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'...
Adam's user avatar
  • 77
2 votes
2 answers
204 views

I have a base class called Attacker that has a update method. The update method moves ...
saiy2k's user avatar
  • 486
-7 votes
2 answers
826 views

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 ...
Paul Manta's user avatar
  • 3,197