Godot for Beginners

Godot Programming Terms

2025-07-19
Godot Programming Terms

Programming Terms Every Godot Developer Should Know

Programming can feel overwhelming when you're just starting out. There are so many terms and concepts that seem confusing at first. But don't worry! In this article, we'll break down the most important programming terms in simple language and show you how they work in Godot.

What is Programming?

Programming is like giving instructions to a computer. Just like you might give someone directions to your house, you give the computer step-by-step instructions to do what you want. In game development, you're telling the computer how to make your game work.

Variables: Storing Information

What it is: A variable is like a box where you can store information. You give the box a name and put something inside it.

The Logic: Think of variables like labeled containers. You can put different types of information in them and change what's inside whenever you need to.

In Godot:

# Creating variables
var player_health = 100
var player_name = "Hero"
var is_alive = true
var player_position = Vector2(50, 100)

# Using variables
print("Player health: ", player_health)
player_health = player_health - 10  # Player takes damage

Functions: Reusable Instructions

What it is: A function is a set of instructions that you can use over and over again. It's like a recipe that you can follow multiple times.

The Logic: Functions help you avoid writing the same code repeatedly. You write the instructions once, give them a name, and then call that name whenever you need those instructions.

In Godot:

# Creating a function
func heal_player(amount):
    player_health = player_health + amount
    print("Player healed by ", amount, " points!")

# Using the function
heal_player(25)  # Heals player by 25 points
heal_player(10)  # Heals player by 10 points

Conditions: Making Decisions

What it is: Conditions let your program make decisions based on what's happening. It's like saying "if this happens, do that."

The Logic: Your program checks if something is true or false, then decides what to do next based on the answer.

In Godot:

# Simple if statement
if player_health > 0:
    print("Player is alive!")
else:
    print("Player is dead!")

# Multiple conditions
if player_health > 75:
    print("Player is healthy!")
elif player_health > 25:
    print("Player is wounded!")
else:
    print("Player is critical!")

Loops: Repeating Actions

What it is: A loop makes your program do something multiple times without you having to write the same code over and over.

The Logic: Loops are like saying "keep doing this until something tells you to stop."

In Godot:

# For loop - do something a specific number of times
for i in range(5):
    print("Count: ", i)  # Prints 0, 1, 2, 3, 4

# While loop - keep doing something while a condition is true
var count = 0
while count < 3:
    print("Loop number: ", count)
    count = count + 1

Arrays: Lists of Information

What it is: An array is like a list where you can store multiple pieces of information in order.

The Logic: Arrays help you organize related information together, like a shopping list or a list of players in your game.

In Godot:

# Creating arrays
var enemies = ["Goblin", "Orc", "Dragon"]
var scores = [100, 250, 500, 750]

# Using arrays
print("First enemy: ", enemies[0])  # Prints "Goblin"
enemies.append("Troll")  # Add new enemy to the list
print("Number of enemies: ", enemies.size())

Objects and Classes: Organizing Code

What it is: A class is like a blueprint for creating objects. An object is an instance of that blueprint with its own data.

The Logic: Think of a class like a cookie cutter. You use the same cutter (class) to make many cookies (objects), but each cookie can have different decorations (properties).

In Godot:

# In Godot, every script is automatically a class
extends CharacterBody2D

# These are properties of our class
var speed = 300
var health = 100

# This is a function in our class
func take_damage(damage_amount):
    health = health - damage_amount
    if health <= 0:
        die()

func die():
    print("Character died!")
    queue_free()  # Remove from the game

Comments: Explaining Your Code

What it is: Comments are notes you write in your code that the computer ignores. They help you and other programmers understand what your code does.

The Logic: Comments are like leaving sticky notes in a book to remind yourself what's important.

In Godot:

# This is a single-line comment
var player_score = 0  # Initialize player score to zero

# This is a multi-line comment
# It can span multiple lines
# to explain complex code

func calculate_damage(base_damage, weapon_multiplier):
    # Calculate total damage by multiplying base damage with weapon bonus
    var total_damage = base_damage * weapon_multiplier
    return total_damage

Scope: Where Variables Live

What it is: Scope determines where in your code a variable can be used. Some variables can be used anywhere, others only in specific places.

The Logic: Think of scope like rooms in a house. Some things (like furniture) can be used in any room, while others (like a shower) only work in the bathroom.

In Godot:

extends Node2D

# Global variable - can be used anywhere in this script
var global_health = 100

func some_function():
    # Local variable - only exists inside this function
    var local_damage = 10
    global_health = global_health - local_damage

func another_function():
    # Can use global_health here
    print("Health: ", global_health)
    # But local_damage doesn't exist here - it would cause an error

Parameters: Passing Information to Functions

What it is: Parameters are pieces of information you give to a function when you call it. They let the function work with different data each time.

The Logic: Parameters are like ingredients in a recipe. The same recipe (function) can make different dishes depending on what ingredients (parameters) you use.

In Godot:

# Function with parameters
func attack(enemy_name, damage):
    print("Attacking ", enemy_name, " for ", damage, " damage!")

# Using the function with different parameters
attack("Goblin", 15)
attack("Dragon", 50)
attack("Orc", 25)

Return Values: Getting Information Back

What it is: When a function finishes its work, it can give you back some information. This is called a return value.

The Logic: Return values are like getting change back when you pay for something. You give the function some information, it does some work, and gives you back a result.

In Godot:

# Function that returns a value
func calculate_bonus_damage(base_damage, level):
    var bonus = base_damage * (level * 0.1)
    return base_damage + bonus

# Using the return value
var total_damage = calculate_bonus_damage(20, 5)
print("Total damage: ", total_damage)  # Prints the calculated damage

Putting It All Together

Here's a simple example that uses many of these concepts:

extends CharacterBody2D

# Variables
var health = 100
var enemies_defeated = 0
var weapon_damage = 25

# Function with parameters and return value
func attack_enemy(enemy_name, enemy_health):
    var damage_dealt = weapon_damage
    var remaining_health = enemy_health - damage_dealt

    print("Attacking ", enemy_name, "!")
    print("Dealt ", damage_dealt, " damage!")

    if remaining_health <= 0:
        print(enemy_name, " defeated!")
        enemies_defeated = enemies_defeated + 1
        return true
    else:
        print(enemy_name, " has ", remaining_health, " health left!")
        return false

# Main game loop
func _ready():
    # Array of enemies
    var enemies = ["Goblin", "Orc", "Troll"]

    # Loop through all enemies
    for enemy in enemies:
        var enemy_health = 50
        var defeated = attack_enemy(enemy, enemy_health)

        if defeated:
            print("Victory! Enemies defeated: ", enemies_defeated)
        else:
            print("Enemy survived!")

Practice Makes Perfect

The best way to learn these concepts is to practice them! Try creating simple scripts in Godot that use these different programming terms. Start with variables and functions, then gradually add more complex concepts like loops and conditions.

Remember, every programmer started as a beginner. Don't worry if you don't understand everything at first - programming is a skill that develops over time with practice and patience.

Happy coding!


More Articles

Godot What Is A Game Enigne?

Godot What Is A Game Enigne?

Making a game with a game engine versus making the whole game from scratch

Why I dont recommend the Unity Game Engine and why it Doesn't Matter

Why I dont recommend the Unity Game Engine and why it Doesn't Matter

Why the choice of game engine is less important than you might think.

Godot Limbo AI Behavior Tree #1

Godot Limbo AI Behavior Tree #1

A guide to help you get started with scene transitions in Godot.