Running a Scene
Overview
A scene made in Quorum Studio is a picture of a game's world: where things are, what they look like and what they are called. It doesn't do anything yet. This page starts with how Quorum draws graphics at all, through one of three graphics systems: OpenGL, WebGL and Vulkan. It then shows how a small program loads a scene and starts it in a game window, and what more that program needs for 3D physics and terrain. Finally, you'll test the hypotheses about physics that you wrote in the last tutorial.
Goals
By the end of this lesson, you can
- Describe what a graphics engine does, and how OpenGL, WebGL and Vulkan differ.
- Load a scene from a program with
LoadScene, using Vulkan. - Run a scene from Quorum Studio, and set it up for 3D physics and terrain.
- Test hypotheses about physics, one change at a time, by sight, by sound and by timing, and record the results.
Warm up
Think of a stage set for a play before the actors arrive. The scenery is all in place, but nothing happens. What has to be added before the play can start? Which parts of a game are like the scenery, and which are like the actors and the script?
Vocabulary
You will be learning about the following vocabulary words:
| Term | Definition |
|---|---|
| Scene file | A file, ending in .qs, that saves everything placed in a scene: each item, its position, its properties, the cameras and the lights. A new scene project keeps it in the Scenes folder. |
| Template | A starting program that can be copied and changed. Quorum Studio's scene projects start with one that loads the scene. |
| Game window | The window a Quorum game opens when it runs. A loaded scene is drawn in it. |
| Physics | The part of a game that makes things fall, collide and push on each other. |
| Graphics engine | The part of a game system that turns a scene into pictures on the screen, by sending drawing instructions to the computer's graphics hardware. |
| OpenGL | A way for programs to draw 2D and 3D graphics, first released in 1992 and used on desktop computers ever since. Quorum uses it unless you ask for Vulkan. |
| WebGL | A version of OpenGL that runs inside a web browser. Quorum uses it when a game runs on a web page. |
| Vulkan | A newer way to draw graphics, first released in 2016. It is faster and gives programs more control. Quorum needs it for terrain, shadows, spotlights and other newer features. |
| Hypothesis | A prediction you can test: a clear statement of what you think will happen and why. |
| Test | Trying something out, one change at a time, to see whether a hypothesis is right. |
New Code to Learn
You will be using the following new pieces of code:
| Quorum Code | Code Example | Explanation |
|---|---|---|
| StartGame() | StartGame() | Opens the game window and starts the game. Main calls it. |
| LoadScene(text path) | LoadScene("Scenes/Scene.qs") | Reads a scene file and adds everything in it to the game. |
| UseVulkan(boolean enabled) | UseVulkan(true) | Draws the game with Vulkan. It must come before StartGame. Terrain, shadows, spotlights and other newer features need it. |
| EnablePhysics3D(boolean flag) | EnablePhysics3D(true) | Turns on physics in the 3D layer. Call it after LoadScene, because the scene sets physics on or off when it loads. |
| AddCollisionListener(CollisionListener3D listener) | AddCollisionListener(me) | Asks the 3D layer to tell this object whenever two items start or stop touching. |
| BeginCollision(CollisionEvent3D event) | action BeginCollision(CollisionEvent3D event) | Runs when two items start touching, such as a ball landing on the floor. |
| FinishCollision(CollisionEvent3D event) | action FinishCollision(CollisionEvent3D event) | Runs when two items stop touching, such as a ball bouncing back up. |
| Audio:Play() | touchSound:Play() | Starts playing a sound and lets the game keep running while it plays. |
| SetGravity3D(number x, number y, number z) | SetGravity3D(0, -10, 0) | Sets which way, and how hard, things fall. -10 is about Earth's pull (9.8), straight down. |
CSTA Standards
For teachers · 2026 CSTA K–12 Computer Science Standards
High School · Data & Analysis
Evaluate a data simulation or visualization to answer a data question, inform decision-making, and identify potential limitations.
Also in 2 other lessons
Middle School · Programming
Use systematic strategies to test, refine, and document changes to a computing technology to meet the intended purpose.
Also in 6 other lessons
High School · Programming
Use documentation, libraries, application programming interfaces (APIs), and other tools in program development.
Also in 5 other lessons
Specialty I · Game Development
Examine the key architectural features of computing hardware and their implications for game development.
Only this lesson so far
Explore
How Quorum draws: graphics engines
Everything you see in a game, from a cube to a mountain to a shadow, has to be drawn on the screen, many times every second. The part of a game system that does this is called a graphics engine. It takes everything in the scene, works out what the camera can see, and sends drawing instructions to the computer's graphics hardware, often called the graphics card or GPU. Quorum's games have a graphics engine built in, so you don't have to write those instructions yourself.
Graphics hardware is made by many companies, so programs talk to it through shared standards, a bit like how every country's power outlets need plugs that fit. Quorum's engine can use three of them, under the hood:
- OpenGL came first. It was released in 1992 by Silicon Graphics, a company that made powerful computers for 3D graphics, and it is now looked after by a group of companies called the Khronos Group. For more than twenty years, it was the way most programs drew 3D graphics on Windows, Mac and Linux. Quorum uses OpenGL unless you ask for something else.
- WebGL brought OpenGL to the web. Released in 2011, also by the Khronos Group, it lets a web page draw 3D graphics without installing anything. When a Quorum game runs inside a web browser, it draws with WebGL.
- Vulkan is the newest. The Khronos Group released it in 2016 as a modern replacement for OpenGL. It is faster and gives programs much more control over the graphics hardware, which makes newer effects possible. On a Mac, Vulkan runs on top of Apple's own graphics system through a translator called MoltenVK.
Because Vulkan is the newest, Quorum's newest graphics features need it. To use
everything in the rest of these tutorials, turn Vulkan on in the program that runs your scene, with one line
before StartGame():
UseVulkan(true)
If a computer can't run Vulkan, Quorum quietly falls back to OpenGL.
What Vulkan adds in Quorum
Turning on Vulkan gives your scenes features that OpenGL in Quorum doesn't have:
- Terrain: the ground of a 3D world, with hills and valleys you shape in the scene editor. A scene with a terrain won't load without Vulkan.
- Shadows: lights such as the sun can cast shadows, so objects look like they're really sitting on the ground.
- Spotlights: cone-shaped lights, like a flashlight or a car's headlights. Under OpenGL they aren't drawn at all.
- Realistic materials: surfaces made from texture sets, with bumps, roughness and other details, such as the grass and rock on a terrain.
- Smoother edges: an option called multisampling that softens the jagged
staircase
edges on 3D shapes.
When Quorum Studio itself runs with Vulkan, its scene editor shows these features while you build. Your game only shows them if its own program turns Vulkan on too.
Make it Real
It's complete. The perfect scene. It's cool. It's clever. It's got monsters. They're amazing! Publish it! Hold on. Scenes are cool, but static. Just because there are images in the application does not mean the game is ready to be published on an app store. The application needs movement, game logic and much more. Every item placed in a scene can be found and changed later in code; the next page, Manipulating a Running Scene, shows how.
The first step is to get the scene into a running program.
A Program That Loads a Scene
To load a scene, use the following template:
use Libraries.Game.Game
class Main is Game
action Main
UseVulkan(true)
StartGame()
end
action CreateGame
LoadScene("Scenes/Scene.qs")
end
action Update(number seconds)
end
end
This template looks like a normal game template, as described in the games tutorials.
The first difference is UseVulkan(true) in Main, which turns on Vulkan before the game starts. The second is one action, LoadScene. It reads a scene file, works out what is inside it, and adds each item, camera and
light to the game. The path is relative to the project's folder, so Scenes/Scene.qs is the scene file in the project's Scenes folder. If the scene has a different name,
change the path to match.
A new scene project in Quorum Studio already has a program like this in SourceCode/Main.quorum. Quorum Studio's version makes a File and gives it the path first, then calls LoadScene with the file. Both do the same thing. Quorum Studio's version doesn't turn on Vulkan
yet, so add the UseVulkan(true) line to Main yourself. For this reason, running a new scene project straight away loads whatever
was placed in its scene and starts the game.
Running the Scene
To run the scene, use any of these:
- the green Run button on the toolbar;
- the Run menu, then Run;
- the keys for Run.
| Action | Windows | Mac |
|---|---|---|
| Run the project | Ctrl+R | Cmd+R |
Quorum Studio builds the project, then the game window opens with the scene loaded. The camera in the game starts where the scene's camera was saved, so the view matches the scene editor's.
A note on focus: in the scene editor itself, Cmd+R or Ctrl+R sets the selected item's scale back to 1. If an item is selected and nothing runs, use the Run button or the Run menu instead.
3D Scenes: Physics and Gravity
A 3D scene can be set up in the editor so items fall or roll, but the template above
doesn't turn physics on. Quorum Studio's 3D scene template adds two lines after LoadScene:
use Libraries.Game.Game
class Main is Game
action Main
UseVulkan(true)
StartGame()
end
action CreateGame
LoadScene("Scenes/Scene.qs")
EnablePhysics3D(true)
SetGravity3D(0, -10, 0)
end
action Update(number seconds)
end
end
Order matters. A scene file remembers whether physics was on in each layer, and the editor saves it
as off. Loading the scene sets it again, so EnablePhysics3D(true) goes after LoadScene. Gravity starts at zero, so without SetGravity3D nothing falls.
Physics only moves the items that ask for it. In the Properties panel, an item that should fall needs Physics Enabled checked and Responsiveness set to Responsive. Ground that should hold things up needs Physics Enabled and Unmovable. Properties explains these, and Gravity in 3D explains gravity in code.
Hearing What Happens: A Beep on Every Bounce
Watching a ball fall only works if you can see the screen. A game can also tell you what happened with sound, so anyone can follow along, including people who use a screen reader. The program below plays a short high beep whenever two items start touching, such as the ball hitting the floor, and a lower beep when they stop touching, such as the ball leaving the floor on a bounce:
use Libraries.Game.Game
use Libraries.Interface.Events.CollisionListener3D
use Libraries.Interface.Events.CollisionEvent3D
use Libraries.Sound.Audio
use Libraries.Sound.AudioSamples
use Libraries.Compute.Math
class Main is Game, CollisionListener3D
Audio touchSound
Audio leaveSound
action Main
UseVulkan(true)
StartGame()
end
action CreateGame
LoadScene("Scenes/Scene.qs")
EnablePhysics3D(true)
SetGravity3D(0, -10, 0)
MakeBeep(touchSound, 880)
MakeBeep(leaveSound, 440)
AddCollisionListener(me)
end
/*
Fills an Audio with a short beep: a tenth of a second of one tone.
The pitch is in hertz: 880 is high, and 440 is lower.
*/
action MakeBeep(Audio sound, number pitch)
Math math
AudioSamples samples
samples:SetChannels(1)
samples:SetSamplesPerSecond(44100)
samples:SetSizeInSeconds(0.1)
integer i = 0
repeat while i < samples:GetSize()
number time = i / 44100.0
samples:Set(i, 0.5 * math:Sine(2 * math:pi * pitch * time))
i = i + 1
end
sound:Load(samples)
end
// Two items have started touching, such as the ball landing.
action BeginCollision(CollisionEvent3D event)
touchSound:Play()
end
// Two items have stopped touching, such as the ball bouncing up.
action FinishCollision(CollisionEvent3D event)
leaveSound:Play()
end
action Update(number seconds)
end
end
Main is Game, CollisionListener3D means this game also listens for collisions, and AddCollisionListener(me) tells the 3D layer to send them to it. Each time two items with Physics Enabled start
touching, Quorum calls BeginCollision, and each time they stop, FinishCollision. MakeBeep builds each sound from numbers instead of loading a sound file: a tenth of a second
of a smooth wave, 880 times a second for the high beep and 440 for the low one.
Listen to a bouncing ball and you'll hear high, low, high, low, with the gaps between the beeps getting shorter as the bounces get smaller. No beeps at all means nothing touched. That makes sound a useful way to test a physics scene.
Scenes with Terrain
A scene can have a terrain: the ground of a 3D world, with hills and valleys. Terrain
is drawn with Vulkan, and it is also solid ground for physics, so the program above, with UseVulkan(true) in Main and physics turned on after LoadScene, is exactly what a scene with terrain needs.
If you forget UseVulkan(true), the program stops while loading the scene and says: "This scene has a
terrain, and a terrain needs Vulkan for now." The fix is to add that line to Main and run again.
Terrain has its own pages, starting with Terrain in a Scene. Loading terrain in a game, and asking it questions, is in Terrain in a Game.
Engage
This activity is the second half of the experiment you started in Properties. There, you and your partner wrote a hypothesis for each physics change: what you thought the ball or cube would do, and why. Now that you can run a scene, it's time to test those hypotheses. The goal is to test each hypothesis fairly, one change at a time, record what really happens, and decide whether the evidence supports it. Don't write new predictions: use the list you already made. Get it out, and make a table with four columns: the change, your hypothesis, what actually happened, and whether the result supports or doesn't support the hypothesis.
Set up the same scene as before: an Unmovable floor (a Cube scaled to 10, 0.2 and 10)
and a Responsive Sphere 3 meters above it, both with Physics Enabled. Use the beeping program from Hearing What Happens
, so every test can be heard as well as seen: a high beep when the ball
lands, and a low beep when it leaves the floor. Run it once without changing anything, so you know what normal
looks and sounds like. Then test your hypotheses one at a time, changing only one thing for each test and putting it back before the next:
- Responsiveness: Unmovable, then Nonresponsive, then Responsive.
- Restitution: 0, then 0.5, then 1, then 1.5, with the floor's at 0.
- Mass: 1, then 100.
- Friction: a cube on the floor tilted to 20 degrees, with friction 0, then 0.5, then 1.
- Gravity:
0, -1.6, 0, then0, -25, 0, then0, 10, 0. - Physics Enabled: turned off on the floor.
- A value that doesn't make sense: a negative mass or restitution.
To measure instead of guessing, use a stopwatch, such as the one on a phone; most phones' stopwatches can be used with a screen reader too. Base each measurement on timing. One partner starts the stopwatch the moment the game window opens and stops it at the first high beep: that's how long the ball took to fall. For bounces, use the lap button at each high beep, and compare the times between beeps: a higher bounce takes longer to come back down, so longer gaps mean bouncier. For the friction test, time how long the cube takes from landing until its last beep, when it slides off the end of the floor. Run each test three times and use the middle time, since starting and stopping a stopwatch by hand is never exact. If you hear no beep at all, that's a result too: write down that nothing touched.
Write every time and sound in your table. When you're done, count how many hypotheses the tests supported. For each one they didn't support, explain what you now think is going on. Finally, choose one result where the simulation behaves differently from the real world, and explain whether that's a mistake in your hypothesis or a limit of the simulation.
Wrap up
A scene is data: a file that says what is in the world and where. A program brings it to life, and a graphics engine draws it, with Vulkan for the newest features. Testing your hypotheses one change at a time is how scientists, and programmers, find out whether their ideas about a system are right. Which of your results surprised you most, and what would you test next? So far the program only loads the scene. What would a game need to know about the items in the scene to make one of them move when a key is pressed?