CodeBlanks Logo Icon CodeBlanks

The scene concept

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 Scene

Scenes 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
└── Ground

A 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

Player.cs
// Sahnedeki nesneleri listele
// sceneObjects dizisini oluştur ve doldur
// Diziyi ekrana yazdır

Sample solution

Player.cs
// 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

Question
const scene = {
    name: "Oyun Sahnesi",
    ____: ["Karakter", "Zemin"]
};
console.log(scene.objects);
Answer
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

All lessons in Beginner