The scene concept
- Game Development course
- Beginner
- Lesson 5/83
- 4 min
Learn what a scene is and how it breaks a game into parts.
What Is a Scene?
A scene is a collection of objects that forms a specific part or screen of a game. The main menu, gameplay area, and results screen can be organized as separate scenes. Each scene can contain its own characters, visuals, and other game objects.
Game
├── Main Menu Scene
├── Gameplay Scene
└── Results SceneScenes help divide a large game into smaller, more manageable parts.
Scene Hierarchy
Objects in a scene can be organized in a tree structure. This structure is called a hierarchy. Child objects such as characters, cameras, or visuals can be placed under parent objects.
Gameplay Scene
├── Character
│ ├── Visual
│ └── Camera
└── GroundA hierarchy makes it easier to view and organize relationships between objects in a scene.
Practice List the Objects in a Scene
Create an array named sceneObjects. Add the values Karakter, Kamera, and Zemin in that order. Print the array using console.log().
Starter code
// Sahnedeki nesneleri listele
// sceneObjects dizisini oluştur ve doldur
// Diziyi ekrana yazdırSample solution
// Sahnedeki nesneleri listele
const sceneObjects = ["Karakter", "Kamera", "Zemin"];
console.log(sceneObjects);Expected output
[ 'Karakter', 'Kamera', 'Zemin' ]
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which structure can be used to manage a game's main menu separately from its gameplay area?
- A separate scene Correct answer
- A new graphics card
- A different programming language
- A new audio file
Explanation: The main menu and gameplay area can be kept in separate scenes. This allows each part to be organized independently.
2 Define the Scene Structure
const scene = {
name: "Oyun Sahnesi",
____: ["Karakter", "Zemin"]
};
console.log(scene.objects);
const scene = {
name: "Oyun Sahnesi",
objects: ["Karakter", "Zemin"]
};
console.log(scene.objects);
Explanation: The objects property keeps the objects contained in the scene together.
3 Scene Concepts
| Term | Meaning |
|---|---|
Sahne |
Contains a specific part of the game |
Hiyerarşi |
Tree-like organization of objects |
Üst nesne |
Can contain child objects |
Oyun alanı |
The area where the player plays the game |