Polymorphism And Inheritance Flashcards

1
Q

What is Polymorphism in Game dev?

A

Polymorphism is a concept that comes into play when we start using inheritance in our code, and using this concept correctly can give Game Debs the ability to alter inherited methods to better suite the derived class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Inheritance in code

A

When we use inheritance in code, we inherit variables and methods from the base class into the Derived class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Inherited methods

A

Based on the problem we are working on, we would want inherited methods to work a bit differently than it did in the base class.
Ie.) In RPGs the player can wield multiple ranged weapons like, a Crossbow, a Longbow, A Ballista
Each will have a different execution as well as different range, fire power, damage, animation, etc, that needs to be coded for each method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Polymorphism steps In game dev

A

Take methods defined in the base class
Inside the derived classes of that base class
We modify its execution, Ie, code
To do different things based on the derived class in question
This allows us to perform a single action in multiple different ways

How well did you know this?
1
Not at all
2
3
4
5
Perfectly