BUILD YOUR FIRST BATTLE GAME

“Where your code stops being polite… and starts throwing punches.”

Welcome to Unit 12 — the moment your Python journey evolves from:

“Look, I can print my name.”
to
“BEHOLD, MY GOBLIN-SMASHING SIMULATOR”

This unit teaches you how to build a real, playable, turn-based battle game using:

  • Dictionaries
  • Functions
  • Loops
  • Items
  • Player choices
  • Win/lose conditions

And the best part?

Everything runs in ONE cell.
Everything works in your LMS.
Everything is beginner-friendly.

Let’s begin.


STEP 1 — Create Your Characters

Because every game needs a hero… and something ugly to punch.

We start by creating two dictionaries:

  • One for the player
  • One for the enemy

Each dictionary stores:

  • A name
  • Health
  • Attack power
player = {"name": "Hero", "health": 100, "attack": 15}
enemy  = {"name": "Goblin", "health": 50, "attack": 8}

print("Battle begins!")
print(player["name"], "vs", enemy["name"])

Explanation:
Dictionaries are perfect for game characters because they hold all the stats in one place.
It’s like giving your hero a backpack full of numbers.

Copy code from above and paste here.