CodeBlanks Logo Icon CodeBlanks

2D and 3D games

Learn the differences between 2D and 3D games and their approaches.

2D Games

2D games are created in a two-dimensional world. Object positions in this world are generally represented using horizontal and vertical axes. Characters and objects are often represented by two-dimensional images called sprites.

   Y
   ↑
   |
   |   ● Character
   |
   +----------→ X

Platform and puzzle games can be developed using a 2D approach.

3D Games

3D games are created in a three-dimensional world. Objects have three position axes: horizontal, vertical, and depth. Characters, buildings, and environment objects are often built using three-dimensional geometric models called meshes.

       Z (Depth)
      /
     ● Character
    /
   +----------→ X
   |
   |
   ↓ Y

With a 3D approach, objects can be viewed from different angles and create a sense of depth.

Practice Print the Type of a 2D Object

To identify a character's visual type in a 2D game, assign the value sprite to the objectType variable and print it.

Starter code

Player.cs
// 2D karakterin görsel türü
const objectType = "";
// Nesne türünü ekrana yazdır

Sample solution

Player.cs
// 2D karakterin görsel türü
const objectType = "sprite";
console.log(objectType);

Expected output

sprite

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which element is commonly used to represent a character's visual appearance in a 2D game?

  • Three-dimensional camera
  • Audio file
  • Sprite Correct answer
  • Mesh

Explanation: A sprite is a two-dimensional image that represents characters and other visual objects in 2D games.

2 Identify the Three-Dimensional Model

Question
const objectType = "____";
console.log(objectType);
Answer
const objectType = "mesh";
console.log(objectType);

Explanation: A mesh represents the geometric structure of three-dimensional objects.

3 2D and 3D Concepts

Term Meaning
2D Two-dimensional game approach
3D Three-dimensional game approach
Sprite Two-dimensional visual
Mesh Three-dimensional geometric model

All lessons in Beginner