In OOP, this refers to a lower-level class using the definition for a higher-level class' methods or properties.
0
votes
0answers
14 views
Java (libGDX) - Inheritance problems
I'm having some issues with inheritance for one of my libGDX projects, I'm making a game similar to (very stripped down) Terraria or Starbound and I am using the TiledMap to load the world, ...
3
votes
2answers
218 views
Space game: inheritance for spaceships?
In a space game I'm writing in C++11, I have a class Spaceship. Now I want to create 3 more spaceship types, how should I do?
Attack type: have a weapon
Research type: have a sensor
Religious type: ...
4
votes
3answers
339 views
Callback on Derived Class?
How does Unity3D implement their system where if a class is derived from MonoBehaviour and has certain methods like Awake() or Update(), they are called accordingly? I want to do a similar system for ...
0
votes
1answer
60 views
Have several classes with a common interface, but still able to access MonoBehaviour methods through that interface?
In our project we used to have a PlayerObject class and then Unit and Building derived from that class. We recently started taking a look at Bolt, which requires classes that define objects that may ...
0
votes
1answer
111 views
Weird inheritance hierarchy?
In my RPG, all Food objects should be possible weapons. For instance, I want the player to be able to to try kill bunnies with a cherry or a watermelon.
The problem is that the easiest way to do this ...
0
votes
1answer
43 views
How to reuse code [closed]
I have three classes.
Monster derives from Animation. Animation derives from Collider. This is, monster is an animated collider.
However, I'd like to have animated objects that are not colliders.
...
0
votes
1answer
156 views
How does super.render() call this method?
Today I was experimenting with adding different screens with Scene2d in libgdx and while doing so I became confused how super.render() in my render() method from my starter class (MyGdxGame) called ...
1
vote
2answers
210 views
Single or multiple inheritance for game world objects
So I am currently laying out on paper the system I want to code for a game in C++.
Now currently I am debating whether to have e.g. a class object_door that inherits from another class ...
0
votes
1answer
330 views
Should I use inheritance or interfaces for an inventory system? [closed]
I'm about to start programmin an inventory, harvest and loot system. I will need enemies that drop items, harvestable environmentals that yield resources and an inventory system that takes items and ...
0
votes
1answer
111 views
How to save a character to be used in all Game States?
I am using C# and SFML.
I am having a problem understanding how to save a character in memory, so I can use the character in any game state.
Right now, the character is a class, and the player ...
1
vote
1answer
185 views
Making specific Enemy Classes
So I was just looking through an old game I had made for android, and was second guessing how I was sub-classing enemy for each particular enemy in my game. My enemy class had all kinds of ...
2
votes
1answer
277 views
Spell classes and inheritance
I'm currently developing a small game, that includes spell casting.
My class structure looks like this:
AbstractSpell
AbstractDamageSpell
AbstractClickableSpell
...
1
vote
1answer
313 views
How to use/apply class inheritance in Enchant.js
You're developing a game using Enchant.js and you just need an Enemy class which multiple enemy classes derive from and every enemy has its own sprite and stuff.
4
votes
2answers
479 views
Game state management: the buck doesn't stop “here” soon enough
I realize there are already many Q&As on this site about GameState/GameScreen management, state machines, state stacks, etc. This question is meant as a follow-up:
Suppose hypothetically I ...
6
votes
2answers
1k views
How should I plan the inheritance structure for my game?
I am trying to write a platform shooter in C++ with a really good class structure for robustness. The game itself is secondary; it is the learning process of writing it that is primary.
I am ...
2
votes
1answer
1k views
Custom inventory items based on inheritance
So, here's the scenario:
I'm building an RPG. Like most of the other RPGs on the market, my game will feature an inventory and of course, inventory items. So far I've worked well with using a single ...
8
votes
2answers
822 views
Doesn't multiple inheritance solve all problems that entity systems do?
The question is pretty self explaining: doesn't multiple inheritance solve all the problems that entity systems also solve?
I just remembered a term called "multiple inheritance", and that seems to ...