Skip to content

Course 4: Three Ursina 3D - 3D Game Development

Course overview

In this course, students learn the an actually playable 3D game. Students learn core game-development skills like physics engines, collision detection, and time control. Beyond just copying code, they develop the ability to understand game mechanics and design their own games.

Estimated time: 12-24 hours

The time required depends on the student's grade level, prior experience, and learning speed, and varies greatly. It also differs between just learning the basic concepts and moving on, versus additional practice problems or creative projects: taking those on makes a difference too. The times above are an average range, so please proceed flexibly at your child's pace.

What abilities will it build?

real-time data processing . A game reads, calculates, and renders data 60 times per second. This is the basic principle behind every system that must process data in real time, such as stock trading systems, self-driving cars, and IoT sensors.

What principles will you learn?

  • (2D data) By building a row×column structure with nested loops, students 2D data structures like Excel sheets, image pixels, and game mapsunderstand them. It's the table form most commonly used in data analysis.
  • (Time-series data) By working with position and velocity data that changes over time, students experience the concept of time-series data. It's the same principle as analyzing change over time in stock prices, temperatures, and heart rates.
AI-era thinking: computing (problem-solving) | data-driven | probabilistic thinking

Computational Thinking

Skill Description Example activity
🔲 Creating a 2D structure Make a grid with nested loops Create a 10×10 block grid
⚛️ Physics simulation Express real-world laws in code Implement gravity, collisions, friction
⏱️ Time control Maintain a constant speed with delta time Frame-independent motion
💥 Collision detection Check for overlap between objects "Game over when touching an enemy"

Mathematical connections

Math concept Programming application Learning benefit
Multiplication principle 5 rows × 4 cols = 20 blocks Counting combinations, computing array size
Velocity formula distance = speed × time position += velocity * time.dt
Gravitational acceleration velocity += gravity * dt Uniformly accelerated motion
Coordinate indexing grid[row][col] 2D array index

Nested Loop Visualization

flowchart LR
    subgraph ROW0["row = 0"]
        A0["(0,0)"] --> A1["(0,1)"] --> A2["(0,2)"] --> A3["(0,3)"]
    end
    subgraph ROW1["row = 1"]
        B0["(1,0)"] --> B1["(1,1)"] --> B2["(1,2)"] --> B3["(1,3)"]
    end
    subgraph ROW2["row = 2"]
        C0["(2,0)"] --> C1["(2,1)"] --> C2["(2,2)"] --> C3["(2,3)"]
    end
    ROW0 --> ROW1 --> ROW2

Total number of iterations: 3 rows × 4 cols = 12 times

Physics simulation formulas

Physics concept Math formula Code expression
Uniform motion x = x₀ + v·t x += speed * dt
Gravitational fall v = v₀ + g·t vy += gravity * dt
Projectile motion Horizontal + vertical combined x += vx*dt, y += vy*dt
💻 Code examples & visualization

Example 1: Nested loops - 3D grid

from ursina import *

app = Ursina()

# Create a 5×5 grid
for row in range(5):
    for col in range(5):
        cube = Entity(
            model='cube',
            color=color.azure,
            position=(col * 2, 0, row * 2),
            scale=0.9
        )

EditorCamera()  # Camera control enabled
app.run()

Nested loop execution order:

row=0: col= 0  1  2  3  4   (5 items)
row=1: col= 0  1  2  3  4   (5 items)
row=2: col= 0  1  2  3  4   (5 items)
row=3: col= 0  1  2  3  4   (5 items)
row=4: col= 0  1  2  3  4   (5 items)
                            ────
                    25 total (5×5)

Result (top-down view):
┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐
│■│ │■│ │■│ │■│ │■│  row=4
├─┤ ├─┤ ├─┤ ├─┤ ├─┤
│■│ │■│ │■│ │■│ │■│  row=3
├─┤ ├─┤ ├─┤ ├─┤ ├─┤
│■│ │■│ │■│ │■│ │■│  row=2
├─┤ ├─┤ ├─┤ ├─┤ ├─┤
│■│ │■│ │■│ │■│ │■│  row=1
├─┤ ├─┤ ├─┤ ├─┤ ├─┤
│■│ │■│ │■│ │■│ │■│  row=0
└─┘ └─┘ └─┘ └─┘ └─┘
col=0 col=1 col=2 col=3 col=4


Example 2: Physics simulation - gravity

from ursina import *

app = Ursina()

player = Entity(model='cube', color=color.red, position=(0, 5, 0))
ground = Entity(model='plane', color=color.green, scale=10)

velocity_y = 0
gravity = -9.8

def update():
    global velocity_y

    # Apply gravity: v = v + g × dt
    velocity_y += gravity * time.dt

    # Update position: y = y + v × dt
    player.y += velocity_y * time.dt

    # Check for floor collision
    if player.y <= 0.5:
        player.y = 0.5
        velocity_y = 0

app.run()

Physics simulation steps:

Time  │ Speed(v) │ Pos(y)   │ State
─────┼─────────┼─────────┼──────
0.0s │  0.0    │  5.0    │ Start
0.1s │ -0.98   │  4.9    │ Falling
0.2s │ -1.96   │  4.7    │ Falling
0.3s │ -2.94   │  4.4    │ Falling
...  │  ...    │  ...    │ ...
1.0s │ -9.8    │  0.5    │ Landed!

     ┌─┐
     │■│ ← Start position (y=5)
     └─┘
       ↓ Gravity
     ┌─┐
═════│■│═════ ← Landing (y=0.5)
     └─┘


Example 3: Time control - slow motion

from ursina import *

app = Ursina()

cube = Entity(model='cube', color=color.orange)
speed = 5

def update():
    # Use time.dt to keep a constant speed
    cube.x += speed * time.dt

    # Toggle slow motion with the spacebar
    if held_keys['space']:
        application.time_scale = 0.2  # 20% speed
    else:
        application.time_scale = 1.0  # Normal speed

app.run()

Why delta time matters:

Without time.dt:
──────────────────────────────
60fps PC:  ■→→→→→→→→→→→→  Fast
30fps PC:  ■→→→→→→        Slow
(Moves a fixed amount per frame)

Using time.dt:
──────────────────────────────
60fps PC:  ■→→→→→→→→→→→→  Same speed
30fps PC:  ■→→→→→→→→→→→→  Same speed
(Moves proportionally to actual elapsed time)


Example 4: World grid - making a map with a 2D array

from ursina import *

app = Ursina()

# Map data (2D array)
map_data = [
    [1, 1, 1, 1, 1],
    [1, 0, 0, 0, 1],
    [1, 0, 2, 0, 1],
    [1, 0, 0, 0, 1],
    [1, 1, 1, 1, 1]
]
# 0=empty space, 1=wall, 2=player

for row in range(5):
    for col in range(5):
        value = map_data[row][col]

        if value == 1:  # Wall
            Entity(
                model='cube',
                color=color.gray,
                position=(col, 0, row)
            )
        elif value == 2:  # Player
            Entity(
                model='cube',
                color=color.red,
                position=(col, 0, row)
            )

EditorCamera()
app.run()

Map data → 3D world:

2D array:             3D world:

[1,1,1,1,1]          ■ ■ ■ ■ ■
[1,0,0,0,1]    →     ■       ■
[1,0,2,0,1]    →     ■   ●   ■
[1,0,0,0,1]    →     ■       ■
[1,1,1,1,1]          ■ ■ ■ ■ ■

■ = Wall (gray)
● = Player (red)
  = Empty space


Example 5: Collision detection

from ursina import *

app = Ursina()

player = Entity(model='cube', color=color.red, collider='box')
coin = Entity(model='sphere', color=color.yellow,
              position=(3, 0, 0), collider='sphere')

score = 0

def update():
    global score

    # Move the player
    player.x += held_keys['d'] * 5 * time.dt
    player.x -= held_keys['a'] * 5 * time.dt

    # Check for collision
    if player.intersects(coin).hit:
        score += 1
        coin.disable()  # Remove the coin
        print(f"Score: {score}")

app.run()

Collision detection principle:

Before collision:
┌───┐          ○
│ ● │ →→→→→   Coin
│   │
└───┘
Player

At collision (intersects = True):
┌───┬──○
│ ● │Coin
│   │
└───┘
→ Score +1, coin removed

After collision:
┌───┐
│ ● │          (Coin gone)
│   │
└───┘
Score: 1


Chapter 01: 3D Basics

A. What Is 3D?

Item Content
What will you learn? The concept of 3D space
Core Concepts Dimensions, coordinate systems, spatial thinking

3D represents space with three axes (x, y, z). If 2D is a flat plane (on paper), 3D is solid (the real world). Students come to understand height, width, and depth programmatically. This connects directly to coordinate geometry in math and improves spatial perception. The same principle is used, such as processing user names and analyzing messages.


B. Entity Basics

Item Content
What will you learn? The basic structure of a game object
Core Concepts Game objects, properties, components

An Entity is the basic unit of everything in the game world. The player, enemies, the floor, items: they're all Entities. Students learn that an Entity has various properties such as position, size, rotation, and appearance . Thanks to this unified structure, they can handle every game element in a consistent way . This connects to the foundational concepts of object-oriented programming.


C. Camera

Item Content
What will you learn? Controlling the player's viewpoint
Core Concepts Viewport, viewpoint, projection

The camera is the eye through which the player sees the game world. You implement various viewpointslike first-person, third-person, and top-down through camera settings. Students experience how the same game world feels completely different depending on the camera. Connecting to the ideas of camera angles and zoom in filmmaking, their Media literacyimproves too. By adjusting the camera's position and rotation, they design the desired gameplay experience.


D. Position and Coordinates

Item Content
What will you learn? Precise positioning and movement
Core Concepts Vectors, relative/absolute position

position = (x, y, z)with an exact position in 3D space. They specify it and understand the difference between absolute position (relative to the world) and relative position (relative to the parent). Students naturally pick up the basics of vector operations: adding, subtracting, and scaling positions. Movement is expressed as position += (dx, dy, dz)like adding a change in value. This concept directly connects, such as processing user names and analyzing messages.


E. Building Your First 3D Scene

Item Content
What will you learn? Composing a scene from multiple objects
Core Concepts Scene composition, level design

the floor, walls, player, and background combine them to build a game environment. Students experience how individual elements come together to form a single world. By adjusting color, size, and placement, they influence the mood and gameplay. This is the foundation of level design, the ability to design the user experience. Students feel the creative sense of accomplishmentof creating their own world.


Project: Nested Loop Visualization (VisualLoop)

Item Content
What will you learn? Create a 2D grid with a double for loop
Core Concepts Nested loops, 2D array concepts

A nested loop is a loop inside a loop. The outer loop handles the rows, and the inner loop handles the columns, to create a grid structure. Students understand that this is the same structure as a spreadsheet, chessboard, or pixel image. With the visualization tool, they can directly observe what order the loops run in . This concept is used in countless fields, such as image processing, game maps, and data tables, such as processing user names and analyzing messages.


Project: Physics and Collisions (Platformer)

Item Content
What will you learn? Gravity, jumping, collision detection
Core Concepts Physics simulation, collision checking

A physics engine gravity, friction, and collisionsautomatically. Students learn how real physics laws are simulated in games . Collision detection is the technique of checking whether two objects overlap, and it's the foundation of every action game. They implement game rules like "stop when touching the floor" or "take damage when touching an enemy". They experience physics concepts (velocity, acceleration, force) in a practical context .


Project: Time Control (Slow Motion)

Item Content
What will you learn? Game speed and time control
Core Concepts Delta time, time scale

time.dt(delta time) is the elapsed time between frames. By adjusting this value, you can create slow motion or fast-forward. Students learn that a game tracks time in real time. By combining this with conditionals, they create dramatic effectslike "time slows down in certain situations." Time management is an important factor that determines a game's pacing and drama.


Project: World Grid (World Grid)

Item Content
What will you learn? Representing game maps with 2D arrays
Core Concepts 2D arrays, map data, procedural generation

You represent a game map as a 2D array (a grid of numbers). For example: 0is empty space, 1is a wall, 2is an enemy's position. Students understand the separation of data and visual representation- a number array is converted into blocks on screen. This is the core structure of countless games, such as Minecraft, Tetris, and Sudoku. By modifying the map data, you can easily generate new levels.


When you finish this course...

Learning outcomes

Students will be able to:

  • Physics engine: understand and apply the basic principles of
  • Collision detection: implement game interactions with
  • Camera and viewpoint: design the game experience by adjusting
  • Nested loops: create a 2D grid structure with
  • Time and speed: create dynamic effects by controlling
  • A simple but actually playable game