What is Programming?
Have you ever wondered how video games, websites, or apps actually work? It might seem like magic, but it’s actually incredibly simple.
The Robot Dog
Imagine you have a shiny new Robot Dog. This dog is incredibly fast, very loyal, and never gets tired. But there is one tiny problem: the dog is completely clueless.
If you throw a ball and yell, "Fetch!", a real dog knows what to do. But your Robot Dog will just sit there and stare at you. It doesn't know what "fetch" means. It only understands tiny, exact, step-by-step instructions.
Writing Instructions
To get the Robot Dog to fetch the ball, you have to break down the job into exact steps. You have to tell it:
- 1Turn your body toward the ball.
- 2Walk forward until you bump into the ball.
- 3Open mouth.
- 4Bite down on the ball.
- 5Turn around and walk back to me.
- 6Drop ball.
That is Programming!
Computers are exactly like that Robot Dog. They are incredibly fast and obedient, but they don't know how to do anything on their own.
Programming is just the act of writing down those tiny, exact steps so the computer knows what you want it to do. When you put a bunch of these instructions together, you create a game, a website, or an app!
Variables
Welcome back to the Robot Dog! In our last lesson, we learned that programming is just giving our computer (the Robot Dog) a list of very exact, step-by-step instructions.
But what happens when our dog needs to remember something?
Imagine you are playing fetch. You throw the red ball, and the dog brings it back. You do this 15 times. If you ask the Robot Dog, "How many times did we play fetch today?" it will just stare at you.
Computers have terrible memories unless we specifically tell them to remember something. To fix this, we use something called a Variable.
The Cardboard Box Rule
Think of a variable as a small, empty cardboard box.
When you want your dog to remember something, you grab an empty box and do three things:
- 1You grab a marker and write a Label on the outside. (So you know what is inside).
- 2You put something inside the box. (The actual information).
- 3You tape it shut and put it in the dog's backpack.
Let’s say you want the dog to remember its own name. You get a box, write DogName on the outside, put a slip of paper that says "Sparky" inside, and pack it away.
Later, when you need to know the dog's name, you don't guess. You just tell the computer: "Hey, go look inside the box labeled DogName and tell me what it says."
How to Build a Box in Code
In programming, creating this box is called Declaring a Variable. Every time we declare a variable, we have to follow a strict recipe. We have to tell the computer what kind of box it is, what its label is, and what goes inside.
Here is how we create variables in the two most popular languages for our projects:
In C# (Used for building Unity Games):
// We label it "numberOfTreats"
// We put the number 5 inside it
int numberOfTreats = 5;
// We are making a box for text (string)
// We label it "favoriteToy"
// We put the words "Red Bouncy Ball" inside it
string favoriteToy = "Red Bouncy Ball";
In Python (Used for automation and AI):
number_of_treats = 5
favorite_toy = "Red Bouncy Ball"
Why are they called "Variables"?
This is the most important part! They are called "Variables" because the information inside the box can vary (which is a fancy word for change).
Let's say you give your dog a treat for being a good boy. The box labeled numberOfTreats shouldn't say 5 anymore. It needs to say 4.
You don't need to build a brand-new box. You just reach into the existing box, throw away the number 5, and put the number 4 in its place.
Here is what that looks like in code:
int numberOfTreats = 5;
// The dog eats one treat!
// We tell the box to equal itself, minus one.
numberOfTreats = numberOfTreats - 1;
// Now, if we check the box, the computer will tell us there are 4 treats left.
Why Does This Matter in Game Development?
If you want to build games, variables are the most important tool in your entire toolbox. Everything you see on a game screen is just a box with a number or a word inside it!
- ✦The Health Bar: Just a box labeled
playerHealth. When an enemy hits you, the game reaches into that box and makes the number smaller. - ✦The Score: A box labeled
totalScore. Every time you collect a coin, the game reaches into the box and adds 10 points. - ✦The Player's Name: A box labeled
playerNamethat stores whatever you typed in at the start menu.
Without variables, games would have no memory. Your score would always be zero, you would never lose health, and your Robot Dog would never remember how many treats he ate!
Data Types
Welcome back to the Robot Dog! In our last lesson, we learned how to use Variables (little labeled boxes) so our dog can remember things.
But what happens if we try to put a bowl of soup into a cardboard box meant for tennis balls? It makes a huge mess!
The Shape-Sorter Toy
Think of a toddler's shape-sorter toy—the one where you push a wooden star through a star-shaped hole, and a square block through a square hole.
When you pack boxes into your Robot Dog's backpack, the dog needs to know exactly what shape of information is going inside. If you tell the dog a box is built for Words, but you try to shove a Math Number inside it, the computer gets confused and crashes.
In programming, the "shape" of the box is called a Data Type.
Building the Right Box
Let's look at how we build specific shapes of boxes in code:
In C# (Used for Unity Games):
int playerLives = 3;
// 'float' is a number with a decimal (needs an 'f' at the end in C#)
float walkSpeed = 5.5f;
// 'string' is for words and text (always in quotes)
string dogName = "Sparky";
// 'bool' is a simple True or False switch
bool isBarking = true;
In Python (Used for automation):
player_lives = 3
walk_speed = 5.5
is_barking = True
Why Does This Matter in Game Development?
Different data types tell the computer how it can interact with the box:
- ✦Math (Integers & Floats): You can only do math on number boxes. If you try to add `5` to `"Sparky"`, the game will break! You use these for Player Health, Ammo counts, and High Scores.
- ✦Text (Strings): Used for dialogue boxes, character names, and the text on the "Game Over" screen.
- ✦Switches (Booleans): Used for states. Is the player dead? `isDead = true`. Is the door locked? `isLocked = false`.
Conditionals
Welcome back! So far, our Robot Dog knows how to take instructions and remember things in labeled boxes. But the real world is unpredictable.
The Weather Rule
Imagine you tell your Robot Dog to go for a walk. But what if it's pouring rain? The dog will just walk outside and get completely soaked because it doesn't know how to think for itself.
To stop this, we need to teach the dog how to make decisions using Conditionals (also known as If-Statements). It's like telling the dog: "IF it is raining, put on your raincoat. ELSE, just grab your leash."
Making Decisions in Code
In C# (Unity Games):
if (isRaining)
{
// The dog checks the sky. If true, run this code:
PutOnRaincoat();
}
else
{
// If it is NOT raining, run this code instead:
GrabLeash();
}
In Python (AI/Automation):
if is_raining:
put_on_raincoat()
else:
grab_leash()
Why Does This Matter in Game Development?
Without conditionals, games would just be movies that play out exactly the same way every time. Conditionals make games interactive!
- ✦Player Death:
IFplayerHealth is exactly 0,THENplay the game over screen. - ✦Unlocking Doors:
IFthe player has the Golden Key in their inventory,THENopen the door.ELSE, display "Locked!" text. - ✦Enemy AI:
IFthe player is close,THENattack.ELSE, just wander around aimlessly.
Loops
Welcome back! Sometimes, we need our Robot Dog to do the exact same thing over and over again.
The Spilled Treats
Imagine you accidentally drop a massive box of 100 dog treats all over the kitchen floor. You tell the Robot Dog: "Pick up a treat and put it in the bowl."
The dog will pick up exactly one treat, put it in the bowl, and then stare at you happily while 99 treats remain on the floor. To get them all, you would have to scream "Pick up a treat!" 100 times in a row. That is exhausting!
Instead, we use a Loop. A loop tells the computer to repeat a set of instructions until a specific goal is reached. You tell the dog: "WHILE there are treats on the floor, pick one up."
Repeating Actions in Code
In C# (Unity Games):
// A 'While' loop runs forever as long as the condition is true
while (treatsOnFloor > 0)
{
PickUpTreat();
treatsOnFloor = treatsOnFloor - 1;
}
In Python (AI/Automation):
while treats_on_floor > 0:
pick_up_treat()
treats_on_floor -= 1
Why Does This Matter in Game Development?
- ✦The Main Game Loop: Every video game actually runs inside one giant infinite loop called the "Update Loop" that repeats 60 times a second to draw the screen!
- ✦Inventory Systems: If a player opens their backpack, a loop quickly goes through every single slot to draw the pictures of their items on the screen.
- ✦Spawning Enemies: Want a horde of 50 zombies? Don't write the "spawn zombie" code 50 times. Write it once inside a loop that counts to 50.
Functions
Welcome back! As you write more instructions for your Robot Dog, things are going to get messy very quickly.
The "Fetch" Shortcut
Remember in Module 1 when we taught the dog to fetch? We had to write out 6 exhausting steps: Turn to ball, walk to ball, open mouth, bite, walk back, drop.
Imagine if every single time you wanted the dog to play fetch, you had to type out all 6 of those instructions again. Your code would be thousands of lines long just to play fetch a few times!
A Function (also called a Method) is a way to bundle up those 6 steps, put them in a box, and slap a single label on it called "Fetch". Now, instead of typing 6 lines of instructions, you just shout "Fetch!" and the dog remembers all the steps inside that box.
Creating a Shortcut in Code
In C# (Unity Games):
void FetchBall()
{
WalkToBall();
BiteBall();
ReturnToOwner();
}
// 2. Now we can trigger all 3 steps easily!
FetchBall();
In Python (AI/Automation):
walk_to_ball()
bite_ball()
return_to_owner()
fetch_ball()
Why Does This Matter in Game Development?
- ✦Jumping: When a player presses the Spacebar, the game calls the `Jump()` function, which calculates physics, plays a sound effect, and plays the jumping animation all at once.
- ✦Taking Damage: An `ApplyDamage()` function can automatically reduce health, make the screen flash red, and check if the player has died.
- ✦Organized Code: Game code gets massive. Functions keep your code clean, readable, and prevent you from repeating yourself (The DRY principle: Don't Repeat Yourself).
Classes
Welcome to the final concept in Programming Basics! It's time to take everything we've learned and build something massive.
The Factory Blueprint
So far, we have been programming one Robot Dog. It has variables (like a name) and functions (like fetching).
But what if you wanted to build an entire army of 1,000 Robot Dogs? Writing the code from scratch for every single dog would take years.
Instead, we create a Class. A Class is simply a factory blueprint. It is a piece of paper that says: "Every time I build a dog, give it a Name Box, an Age Box, and the ability to Fetch." Once you have the blueprint, you can stamp out 1,000 unique dogs instantly!
Drawing the Blueprint in Code
In C# (Unity Games):
public class RobotDog
{
public string dogName;
public void Fetch() { ... }
}
// 2. Building real dogs using the blueprint!
RobotDog myDog = new RobotDog();
myDog.dogName = "Sparky";
myDog.Fetch();
In Python (AI/Automation):
def __init__(self, name):
self.name = name
def fetch(self):
pass
my_dog = RobotDog("Sparky")
my_dog.fetch()
Why Does This Matter in Game Development?
Classes are the heart of Object-Oriented Programming (OOP) and modern game engines like Unity. Everything in your game is built from a blueprint!
- ✦Weapons: You create a single `Weapon` class (blueprint). Then you use it to stamp out a Sword, an Axe, and a Bow, just changing their "damage" variable.
- ✦Enemy Spawners: Instead of writing code for every Goblin individually, you write one `Goblin` class. The game engine then clones it 50 times to build an army.
- ✦Modularity: If you find a bug where the dogs fetch the ball wrong, you don't fix 1,000 dogs. You fix the blueprint once, and all 1,000 dogs instantly work correctly!
What is an IDE?
Welcome back! By now, you know that programming is just giving exact instructions to a very fast, but very clueless Robot Dog. But where do you actually write these instructions?
The Problem with Plain Paper
Imagine writing your instructions on a plain piece of paper. You hand the paper to the dog. But wait—you misspelled the word "fetch" as "fetcg". What does the dog do? It completely freezes. It doesn't guess what you meant; it just crashes.
Writing code in a plain text file (like Notepad) is exactly like this. It gives you zero help. This is why programmers invented the IDE, which stands for Integrated Development Environment.
The High-Tech Workshop
Think of an IDE as a High-Tech Training Facility or Workshop for your dog. It is a special piece of software designed specifically to help you write, test, and fix your instructions without the headache.
🖍️ Magic Markers (Syntax Highlighting)
In the workshop, you don't write in boring black ink. The IDE uses Magic Markers to automatically color-code your words. Commands might turn blue, variables might turn green, and numbers might turn yellow. If a word stays white, you instantly know you misspelled it!
🧠 The Mind Reader (Autocomplete)
As soon as you type the letters "fe", the workshop realizes you are trying to write "fetch". A little menu pops up suggesting the word! You just hit Enter, and it finishes typing it for you. This saves massive amounts of time and completely prevents spelling errors.
🔴 The Big Red Button (The Compiler / Play Button)
Instead of handing the paper to the dog and hoping for the best, the workshop has a Big Red Button. When you press it, the IDE safely reads your code and points out any errors before the dog even tries to run them.
Why This Matters in Game Development
Modern video games require thousands, sometimes millions of lines of code. If you miss a single semicolon, the entire game will refuse to open. Without an IDE (like Visual Studio for Unity), finding that missing semicolon is like finding a needle in a haystack.
With an IDE, the software literally puts a giant red squiggly line under the error and says, "Hey! You forgot a semicolon right here!" It is an absolute superpower.
Agentic IDEs
You now have a High-Tech Workshop (your IDE) to help you write instructions. But you still have to type out every single tiny step for the dog. What if you didn't have to?
Hiring the Master Trainer
An Agentic IDE (like Cursor, Windsurf, or GitHub Copilot) takes the standard workshop and adds something incredible: Artificial Intelligence.
Using an Agentic IDE is like hiring a Master Dog Trainer to sit right next to you in the workshop. Instead of you painstakingly writing out the 20 micro-steps needed to make the dog do a backflip, you just turn to the trainer and say, "Hey, I need the dog to jump, flip backward, and bark."
The Master Trainer instantly grabs the pen and writes out all 20 steps perfectly.
💬 The Assistant (AI Chat)
You can ask the trainer questions directly! If your dog keeps bumping into walls, you can ask the AI, "Why is my player character getting stuck?" The AI will scan all of your instructions, find the bug, and tell you exactly how to fix it.
🪄 The Magic Pencil (Inline Generation)
While writing code, you can type a simple human sentence like // make the player jump. The trainer instantly reads your note and writes the actual C# code required to make the jump happen right below it.
The "Architect" Mindset
"If the AI writes the code, am I still a real programmer?"
Absolutely yes. The Master Trainer is fast, but they have no idea what game you are trying to build. They don't know the story, they don't know the rules, and they don't know when the trick should be performed.
When you use an Agentic IDE, you graduate from being a typist to being an Architect. You design the overall system, you tell the trainer what pieces you need, and most importantly: you must review and approve the instructions the trainer writes. If the trainer makes a mistake (and they do!), you need to know enough programming basics to spot the error and fix it.
Why This Matters in Game Development
Making a video game involves a lot of repetitive, "boilerplate" code—like setting up basic movement controls or a health bar system. An Agentic IDE can write these boring, standard parts in seconds.
This means solo developers and small indie teams can now build massive games that used to require a 50-person studio. The AI handles the typing, while you handle the creativity!
Congratulations! You have completed Programming Basics. You now understand how code actually thinks and operates behind the scenes.