Skip to content

Your First 3D App - Part D: Quiz and Next Steps


Quiz: Check the basic concepts

Solve the quizzes below to check what you've learned!

Quiz 1: What is a library?

Quiz: What is a library?
In programming, what is a **library**?
Show Answer

Answer: B) A collection of code that other people have already written

A library is a collection of useful code that other programmers have already written. Just like borrowing a book from a library to read, we can import and use libraries.

For example: - math library: math calculation functions - datetime library: handling dates and times - ursina library: 3D game development tools

Quiz 2: What is the Ursina engine?

Quiz: What is the Ursina engine?
What does the Ursina engine make easy?
Show Answer

Answer: A) It lets you build 3D games and applications in Python

The Ursina engine is a specialized library that lets you make 3D games in Python.

With Ursina, you can: - Easily create 3D objects (cubes, spheres, etc.) - Create and manage a game window - Use cameras, lighting, and physics effects - Handle mouse and keyboard input

Making a 3D game with plain Python alone is hard, but with Ursina you can get started easily!

Quiz 3: Importing a library

Quiz: Importing a library
from ursina import *in * โ€” what does it mean?
Show Answer

Answer: C) It means importing all features

import *in * means "everything." It imports all of the Ursina library's features at once.

Check the first line of the code:

from ursina import *  # Import everything

By doing this, Ursina(), Entity(), color you can use things like this right away.

If you want to import only specific features:

from ursina import Entity, color  # Import only specific features

Quiz 4: The role of app.run()

Quiz: the role of app.run()
app.run()what does it do?
Show Answer

Answer: A) Launches the game window and shows it on screen

app.run()is the function that runs the game window and displays it on the screen. Without this line, no matter how much code you write, the window won't appear!

Check the last line of the code:

app = Ursina()  # Prepare the game
# ... code that creates cubes, cameras, etc. ...
app.run()  # Run the game window and display it on screen!

app.run()When you call it, the game loop starts and keeps running until the user closes the window.

Quiz 5: The role of variables

Quiz: The role of a variable
cube_size = 2what is the role of the variable cube_sizewhat is its role?
Show Answer

Answer: B) It stores the cube's size information

A variable is like a box that holds information. cube_size We store the number 2 in a variable, and later use this value when creating an Entity.

Check it in the code:

cube_size = 2  # Store the information
my_cube = Entity(scale=cube_size)  # Use the stored information


Common mistakes

Here are common mistakes students make and how to fix them.

Mistake 1: Forgetting app.run()

# Wrong code
from ursina import *
app = Ursina()
my_cube = Entity(model='cube', color=color.red)
# app.run() is missing!

Symptoms: Nothing appears even when you run the code. Fix: On the last line, add app.run().

# Correct code
from ursina import *
app = Ursina()
my_cube = Entity(model='cube', color=color.red)
app.run()  # Always add this line!

Mistake 2: Leaving out the Ursina import

# Wrong code
app = Ursina()  # NameError: name 'Ursina' is not defined

Symptoms: NameError: name 'Ursina' is not defined an error occurs. Fix: At the very top of the file, from ursina import *Add

# Correct code
from ursina import *  # This line first!
app = Ursina()

Mistake 3: Typo in a variable name

# Wrong code
cube_color = color.red
my_cube = Entity(
    color=cube_colour  # Wrong - British spelling!
)

Symptoms: NameError: name 'cube_colour' is not defined Fix: Type the variable name exactly (cube_color)

# Correct code
cube_color = color.red
my_cube = Entity(
    color=cube_color  # Correct spelling!
)

Caution

Python is very sensitive to spelling. You have to type variable names exactly!


Next step

Congratulations! You've successfully built your first 3D app!

Review Checklist

Check whether you understood the following:

  • [ ] from ursina import *Do you understand what it means?
  • [ ] Ursina()to create a game window?
  • [ ] Can you use variables to store information?
  • [ ] Entity()to create 3D objects?
  • [ ] app.run()do you know its role?

Challenge

Once you've solved all the quizzes, try the following:

  1. Easy: Change the cube's color to blue
  2. Hint: cube_color = color.blue

  3. Middle: Change the cube's size to 5

  4. Hint: cube_size = 5

  5. Hard: Create one more green cube at a different position

  6. Hint: Create a new Entity and position add the argument
Challenge hint

Task 1 Hint: cube_color Change the value of the variable to color.redin color.blue

Task 2 Hint: cube_size Changing the variable from 2 to 5 makes the cube much bigger

Task 3 Hint:

another_cube = Entity(
    model='cube',
    color=color.green,
    position=(3, 0, 0)  # Move 3 units to the right
)

Next lesson

Lesson 02: Entity Arguments

In the next lesson: - You'll learn the various Entity arguments (model, color, position, scale) - You'll create multiple 3D objects - You'll learn how to adjust the position of objects

Go to the next lesson

Practice matters!

Run and modify this code yourself! Try changing the variable values to see what happens.

cube_size = 5           # Change from 2 to 5 to make the cube bigger!
cube_color = color.blue  # Change color.red to color.blue to make the cube blue!

Changing the variable values changes how the game looks!

Key Summary
  • A library is a collection of code that other people have made
  • The Ursina engine lets you make 3D games with Python
  • A variable is a box that holds information
  • Entity is the function that creates 3D objects
  • app.run()is the command that runs the game