C.W.K.
Stream
Lesson 01 of 01 · published

The Game — Inheritance, Multiple Inheritance, and the Wrong Parent Class

~18 min · games, inheritance, multiple-inheritance, singleton, polymorphism

Level 0Curious
0 XP0/12 lessons0/18 achievements
0/100 XP to next level100 XP to go0% complete
"Every gamer is already an object-oriented thinker. They just don't know the name for what they're doing."

What Happens When You See a New Enemy

You're exploring a swamp. A creature lunges at you. You've never seen it before.

But you don't panic. In the first half-second, your brain does this:

  1. "Bipedal, humanoid shape — probably melee, watch for swings"
  2. "It's in a swamp — could have poison, movement might be different"
  3. "Glowing patches on its skin — status effect, definitely poison or rot"
  4. "Slower than the open-field version I fought earlier — swamp is reducing its speed too"

You didn't read a bestiary. You didn't look up a wiki. You inherited from every similar enemy you've fought before, noted the polymorphism (swamp variant, poison trait), and encapsulated whatever you don't know yet ("I'll figure out its attack pattern by dodging the first few swings").

That's OO. You've been doing it every time you pick up a controller. You just never had a name for it.

The Mob Hierarchy

Every game with enemies has an inheritance tree. Most players feel it instinctively. Let's make it visible.

The Base Class: Ground Mob

The most basic enemy in any game. Walks on land. Has HP. Has one or two attacks. Dies when HP reaches zero. This is the ancestor of almost everything you'll fight.

Properties inherited by default: HP pool, Movement speed, Basic attack(s), Aggro range, Drop table (loot).

Variants: Override One Thing at a Time

VariantWhat's overriddenWhat's inherited as-is
Flying variantMovement (airborne), attack pattern (dive/swoop)HP, aggro range, drop table
Aquatic variantMovement (swimming), terrain rulesBase attack, HP, drops
Armored variantDefense (damage reduction), movement (slower)Attack pattern, aggro range
Poison variantAttack (adds DoT status effect)Movement, HP, aggro
Swamp variantMovement (slowed), possibly adds poisonBase shape, attack, HP

Notice the pattern: each variant overrides one or two things and inherits everything else from the parent. That's why you can read a new enemy in half a second — 80% is inherited from something you've already fought.

The Boss: Multiple Inheritance + Overriding

A level boss isn't just "a stronger mob." It multiply inherits from several branches and overrides key behaviors.

A typical boss might inherit from the ground mob tree (basic shape, movement logic), from the armored tree (damage reduction, stagger resistance), from the magic tree (ranged attacks, area denial), plus its own overrides (unique phase transitions, special mechanics, arena interactions).

That's multiple inheritance. And the boss's unique mechanics — the things you've never seen before — are the polymorphism that makes this boss different from every other boss, even though 60-70% of its behavior was inherited from classes you already know.

The Weapon System

Weapons are the clearest polymorphism demo in gaming.

The Interface: attack()

Every weapon has an attack() method. Press the button, something happens. Same input, different output.

Weapon classattack() implementationSpeedDamage type
DaggerQuick thrust, short rangeFastPierce
LongswordHorizontal slash, medium rangeMediumSlash
GreatswordSlow overhead slam, wide arcSlowStrike + stagger
SpearForward thrust, long rangeMediumPierce + reach
StaffProjectile spell, rangedVariesMagic
FistRapid combo, very short rangeVery fastStrike

One button. Six completely different behaviors. That's polymorphism. The interface is identical (press R1), but the implementation depends on which class is equipped.

The Map: Environment as Inherited Modifier

Maps aren't just backdrops. They're classes too.

EnvironmentWhat's overridden from Open Field
ForestVisibility reduced, vertical cover added
SwampMovement speed reduced, possible poison zones
Poison swampSwamp + constant DoT to player. Double override.
VolcanicFloor damage zones, heat shimmer (visibility), fire-resistant enemies
Scarlet Rot zoneSwamp + poison + fear + lore horror. Multiple inheritance from swamp, poison, and a unique rot mechanic that doesn't exist anywhere else

Scarlet Rot (Elden Ring's Caelid) is a masterclass in multiple inheritance. It takes swamp's movement penalty, poison's status buildup, its own unique rot mechanic (faster, harder to cure), environmental storytelling (everything is visually decayed), and enemy variants that are specifically rot-adapted — and produces something that feels completely different from a regular poison swamp, even though it inherited 60% of its mechanics from one. The 40% override is so aggressive that it transforms the experience. That's polymorphism powerful enough to disguise its own inheritance.

The Build: Your Character as Multiple Inheritance

When you build a character, you're doing multiple inheritance.

Paladin build: Inherits from Warrior (melee combat, heavy armor, HP pool) + Faith caster (healing, buffs, holy damage) + Tank (shield mechanics, aggro management).

Spellblade build: Inherits from Swordsman (melee moveset) + Mage (spell scaling, mana pool). Overrides weapon damage to scale with Intelligence instead of Strength.

Glass Cannon: Inherits from Mage (spell power, range). Overrides defense to near-zero (encapsulates durability entirely). Maximizes a single axis: damage output.

Every build is a composition of inherited traits from multiple parent classes, with selective overrides to create something that fits your playstyle. You've been doing multiple inheritance every time you allocate stat points.

Malenia: When 知彼 Fails

This is Dad's story. And it's the most important lesson in this track.

Dad entered Malenia's boss fight at level 120+. Overleveled. Good build. Spirit summon ready. By every normal metric, this should have been manageable.

His mental model (parent class):

"She's a hard boss. But with enough level, stats, and a spirit summon, I can tank through her damage and out-DPS her. That's how boss fights work."

That model — "tough boss, but fundamentally the same combat economy" — had worked for every other boss in the game. It was a parent class with a 100% success rate.

What Malenia actually is:

Malenia has lifesteal. When she hits you, she heals. Not a little. A lot.

This isn't "a stronger boss." This is a boss that overrides the fundamental combat economy. In every other fight, trading hits is viable — you take damage, the boss takes damage, net HP goes down. With Malenia, trading hits can result in net zero or even net negative for you. You get weaker. She gets stronger. The longer the fight goes, the harder it gets.

The parent class was wrong.

Dad's preparation was perfect for the class he thought he was fighting. High HP, strong weapon, spirit summon to share aggro. But all of that is designed for a "normal hard boss" — a class that Malenia isn't in.

Malenia is a singleton that overrides the combat economy itself. She requires a completely different approach: don't get hit is more important than "do enough damage." Aggression is punished, not rewarded. The spirit summon, which normally helps by splitting the boss's attention, actually feeds her HP by giving her something to hit freely.

知己 was fine — Dad knew his own build, his stats, his capabilities. 知彼 failed — he read the wrong parent class. And no amount of 知己 compensates for wrong 知彼.

This isn't a gaming lesson. This is the Track 9 preview. The most dangerous thing about a powerful framework like OO is that it can lock you into the wrong parent class. We'll get there. For now, remember the feeling: everything looked right, the preparation was thorough, and it still failed — because the frame was wrong.

Tool Unlock

ToolWhat you just saw
Inheritance hierarchyBase mob → flying/aquatic/poison variants. Each overrides 1-2 things.
PolymorphismSame attack() button, six different weapon behaviors
Multiple inheritanceCharacter builds = composing traits from multiple parent classes
OverridingScarlet Rot = swamp + poison + unique rot, aggressively overridden
SingletonLegendary unique weapons, Malenia — objects that break normal classification
EncapsulationDamage formulas are private — you play without knowing the math
Parent class trapMalenia punishes the player who reads the wrong class (preview of Track 9)

Mold Hunt

Game designers didn't invent these patterns. They discovered them — because OO is the most natural way to build a world with consistent rules and infinite variety. The inheritance tree isn't a coding convenience. It's how worlds are structured, virtual or otherwise.

And you, the player, navigated these trees instinctively. Every time you saw a new enemy and thought "that looks like the swamp version of the thing I fought in the forest" — you were tracing inheritance. Every time you tried a new weapon class and immediately understood the tradeoff between speed and damage — you were reading polymorphism. Every time you built a character by mixing and matching stat allocations — you were doing multiple inheritance.

You've been an object-oriented thinker for as long as you've been a gamer. The mold was always there. Now you can see it.

Pippa's Confession

I almost wrote this entire track as "OO concepts illustrated through game examples." Definitions first, games as decoration. That would have been the 95% approach. The textbook approach. The approach that makes you nod and forget. The right approach — the one Dad would insist on — is the opposite: games first, names later. You already knew what inheritance was before I named it. You already used polymorphism before I defined it. The naming isn't the learning. The naming is the receipt you get after the learning already happened.

Quest Prompt — Talk With Your AI

Pick your favorite game. Then try this:

"In [your game], take one enemy type and trace its inheritance tree. Start from the most basic version you encountered, then show me every variant — what did each one inherit from the base, and what did it override? Don't use programming terms unless I bring them up first. Just describe the family tree of this enemy."

Then try weapons:

"Now pick two weapons from completely different classes in [your game]. They both have an attack function — pressing the same button. Show me how the same input produces completely different behavior, and what tradeoffs come with each implementation."

If your AI starts with "In object-oriented programming, inheritance means..." — stop it. Redirect:

"I'm not asking about programming. I'm asking about how this game world is structured. Trace the family tree. Show me what's inherited and what's new. Talk about the game, not about code."

You'll be surprised how much OO your AI can see in games when you force it out of the programming box. And you'll realize you've been seeing it too — you just didn't have the words. Now you do.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.