Course 2: One Basics - Intro to 3D Games
Course overview
In this course, students leap from 2D turtle graphics into the world of 3D games. Using the Ursina engine, they create and manipulate three-dimensional objects, building an understanding of 3D space and the basics of game development. Making a 3D program that actually works gives students a great sense of accomplishment and motivation.
Estimated time: 8-16 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?
Everything in 3D space is represented by numeric data such as position (x, y, z), size, and rotation. Students learn how to model the real world with data. This is the same principle by which self-driving cars perceive space, VR/AR builds virtual worlds, and 3D printers make objects.
What principles will you learn?
- (object data) A 3D object's position, size, and color are all Number data. By storing this data in variables and changing it, students directly observe the effect data has on reality (the screen).
- (parameterization) By passing different values to a function and seeing the results change, they understand the principle that output is determined by input data. This is the basis of every data-processing system.
AI-era thinking: computing (problem-solving) | data-driven | probabilistic thinking
Computational Thinking
| Skill | Description | Example activity |
|---|---|---|
| 📦 Spatial visualization | Expressing position with a 3D coordinate system | position=(2, 1, -3) -> understand the x, y, z axes |
| 🌳 Hierarchy | Organizing objects with parent-child relationships | car (parent) -> wheel (child) |
| ⚙️ Manipulating properties | Changing an object's characteristics | cube.scale = 2 -> 2x size |
| 🔌 Understanding APIs | Learning how to use a library | Figure out the arguments of the Entity() function |
Mathematical connections
| Math concept | Programming application | Learning benefit |
|---|---|---|
| 3D coordinate system | position=(x, y, z) |
Expressing a point's position in space |
| Vectors | scale=(2, 1, 0.5) |
A quantity with direction and magnitude |
| Ratio and scale | scale=2 -> scale up 2x |
Understanding proportional relationships |
| Rotation and angles | rotation=(0, 45, 0) |
The concept of rotation about three axes |
Spatial reasoning skills
flowchart LR
A[3D coordinate system] --> X[X axis: left/right]
A --> Y[Y axis: up/down]
A --> Z[Z axis: front/back]
| Axis | Direction | Example |
|---|---|---|
| X-axis | Left/right (<- ->) | x=3 -> 3 to the right |
| Y-axis | Up/down (^ v) | y=2 -> 2 up |
| Z axis | Front/back (depth) | z=-5 -> 5 back |
Understanding object relationships
💻 Code examples & visualization
Example 1: Your First 3D Cube
from ursina import *
app = Ursina() # Start the game engine
# Create a 3D cube
cube = Entity(
model='cube',
color=color.red,
position=(0, 0, 0)
)
app.run() # Run the game
3D coordinate system:
Example 2: Manipulating Entity Properties
from ursina import *
app = Ursina()
# An Entity with various properties
my_cube = Entity(
model='cube',
color=color.azure,
position=(2, 1, 0), # x=2, y=1, z=0
scale=(2, 0.5, 1), # width 2, height 0.5, depth 1
rotation=(0, 45, 0) # rotated 45 degrees about the Y axis
)
app.run()
Property visualization:
position = (2, 1, 0)
─────────────────────
Y
│ ┌───┐
1 │ │ ■ │ <- cube position
│ └───┘
0 ┼─────────── X
0 1 2
scale = (2, 0.5, 1)
─────────────────────
width 2x │████████│
height 0.5x <- flattened
depth 1x (default)
rotation = (0, 45, 0)
─────────────────────
╱╲
╱ ╲ <- rotated 45° about the Y axis
╱ ╲
Example 3: Creating Multiple Objects
from ursina import *
app = Ursina()
# Ground
ground = Entity(
model='plane',
color=color.green,
scale=10
)
# Player (red cube)
player = Entity(
model='cube',
color=color.red,
position=(0, 0.5, 0)
)
# Trees (green cubes)
for i in range(3):
tree = Entity(
model='cube',
color=color.lime,
position=(i * 3 - 3, 1, 2),
scale=(0.5, 2, 0.5)
)
app.run()
Scene layout:
Side View:
🌲 🌲 🌲
│ │ │
■ (player)
━━━━━━━━━━━━━━━━━━━━━━━ (ground)
Top View:
🌲 🌲 🌲
│ │ │
─────────────────────
│ │ │
■ (player)
Example 4: Parent-Child Relationships
from ursina import *
app = Ursina()
# Parent: car body
car = Entity(
model='cube',
color=color.blue,
scale=(2, 0.5, 1)
)
# Children: wheels (move with the parent)
wheel1 = Entity(
model='sphere',
color=color.black,
scale=0.3,
position=(-0.8, -0.3, 0),
parent=car # <- set as a child of car
)
wheel2 = Entity(
model='sphere',
color=color.black,
scale=0.3,
position=(0.8, -0.3, 0),
parent=car # <- set as a child of car
)
# when the car moves, the wheels move too
car.x = 3 # move car -> wheel1, wheel2 move too
app.run()
Parent-Child relationship:
car (parent) after car.x = 3 move
┌─────────┐ → ┌─────────┐
│ │ │ │
◯ ◯ ◯ ◯
wheel1 wheel2 wheel1 wheel2
move the parent -> the children move along automatically!
Example 5: Color and Transparency
from ursina import *
app = Ursina()
# Opaque cube (default)
cube1 = Entity(
model='cube',
color=color.red,
position=(-2, 0, 0)
)
# Semi-transparent cube (alpha=0.5)
cube2 = Entity(
model='cube',
color=color.rgba(0, 0, 255, 0.5), # Semi-transparent blue
position=(0, 0, 0)
)
# Nearly transparent cube (alpha=0.2)
cube3 = Entity(
model='cube',
color=color.rgba(0, 255, 0, 0.2), # Nearly transparent green
position=(2, 0, 0)
)
app.run()
Transparency visualization:
Chapter 01: Your First 3D App (Hello Ursina)
A. Importing the Ursina Library
| Item | Content |
|---|---|
| What will you learn? | Importing the 3D game engine library |
| Core Concepts | Importing libraries, frameworks |
from ursina import *is a professional game-development toolbox. Ursina is an engine that makes it easy to build 3D games in Python. Students learn that even without doing the complex 3D graphics math themselves, the library handles it for them. This is the "don't reinvent the wheel" principle that is central to modern software development. Even professional developers use proven libraries and frameworks to cut development time.
B. Making a Game Window
| Item | Content |
|---|---|
| What will you learn? | Creating an application instance |
| Core Concepts | Object instantiation, application structure |
app = Ursina()and app.run()is is responsible for starting and running the game. Students learn that a program doesn't just run top to bottom; it runs continuously through an event loop. There is a continuous process of opening the game window, waiting for user input, and refreshing the screen. This is a much more advanced application structure than turtle graphics' done(). Students come to understand the basic structure of an interactive program that responds in real time.
C. Declaring Variables (in a 3D Context)
| Item | Content |
|---|---|
| What will you learn? | Storing a 3D object in a variable |
| Core Concepts | References, object management |
In a 3D environment, a variable references an object shown on screendoes this. my_cube = Entity(...). If you store a cube in a variable, you can later move, rotate, and resize that cube. Students learn that a variable can store not only simple numbers or strings but also complex objects. When managing many objects, giving each a meaningful name is important for code readability. This concept is the foundation for managing many elements such as the player, enemies, and items in a game.
D. Making a 3D Cube with Entity
| Item | Content |
|---|---|
| What will you learn? | Creating an object in 3D space |
| Core Concepts | 3D coordinates, properties, arguments |
Entity is, in Ursina, the basis of every 3D objectIt is. Entity(model='cube', color=color.red, position=(0, 0, 0)), specifying shape, color, and position. Students encounter the 3D coordinate system (x, y, z) for the first time, learning that x is left/right, y is up/down, and z is front/back. They also learn how to pass multiple arguments (keyword arguments) to a function. The shift from 2D to 3D is an important step that expands spatial reasoning.
E. Final Code and Running It
| Item | Content |
|---|---|
| What will you learn? | Understanding the overall program structure |
| Core Concepts | Code structure, order of execution |
The finished code has the structure import -> create app -> create objects -> run. Students understand what each part does and why the order matters. They can edit the code and see the result visually right away, which makes experimental learning possible. They come to see that this simple program is the foundation of more complex games. Students experience the sense of accomplishment of having built their own 3D world.
Chapter 02: Variables and Arguments (Cube Deep Dive)
A. Entity Argument Basics
| Item | Content |
|---|---|
| What will you learn? | Setting various properties of an Entity |
| Core Concepts | Keyword arguments, understanding APIs |
An Entity is model, color, scale, position, rotation etc. various arguments. Students develop the ability to read documentation and find the available options. Through experimentation, they understand which aspect of the object each argument controls. scale=(2, 1, 1)like specify each axis's value individually as a tuple. This experience teaches a transferable way of learning that applies when learning the APIs of other libraries later.
B. Storing an Entity in a Variable
| Item | Content |
|---|---|
| What will you learn? | Storing an object and manipulating it later |
| Core Concepts | References, object modification |
player = Entity(...)Storing it lets you player.position = (1, 0, 0)like change its properties later. Students learn that even after an object is created, it can be modified dynamically. This is the foundation of game logic, where a character moves, health changes, and state changes. They also understand that if you don't store it in a variable, you have no way to access that object later. planned code structureThey begin to learn the importance of
C. Understanding Depth (the z-axis)
| Item | Content |
|---|---|
| What will you learn? | The concept of depth in 3D space |
| Core Concepts | z-axis, camera viewpoint, perspective |
The z-axis represents the into/out of the screen direction. Even objects of the same size, if their z value is large, are farther away and so look smaller. Students learn that the camera's viewpoint matters in 3D space. Experiencing the principle of perspective through programming, they integrate mathematical and artistic concepts. This understanding is essential for placing the background, foreground, and characters appropriately in a 3D game.
D. Alpha and Parent-Child Relationships
| Item | Content |
|---|---|
| What will you learn? | Adjusting transparency and object hierarchy |
| Core Concepts | Transparency, hierarchical relationships, relative position |
color.rgba(1, 0, 0, 0.5)The fourth value (alpha) determines alpha. In a parent-child relationship, the child object moves with the parent. For example, a car's (parent's) wheels (children) move along when the car moves. Students learn how to organize a complex structure hierarchically. This concept is used to model real-world relationships such as a robot arm, the solar system, and character joints.
E. Methods and Common Mistakes
| Item | Content |
|---|---|
| What will you learn? | Understanding object behavior (methods) and avoiding errors |
| Core Concepts | Method calls, debugging |
A method is an action an object can performIt is. player.look_at(target), so you can give the object commands. Students understand the difference between properties (data) and methods (behavior). They learn common mistakes (typos, wrong arguments, missing commas, etc.) and how to fix them. They build the debugging skill of reading and interpreting error messages.
When you finish this course...
Learning outcomes
Students will be able to:
- 3D coordinate system (x, y, z) and use it
- Import and use a game engine library
- Create Entity objects and manipulate their properties
- Use keyword arguments to set various properties of an object
- the object's Build hierarchical (parent-child) relationships
- Be ready to learn more complex game logic (movement, collisions, etc.)