Urgent.News

What's breaking now, across thousands of outlets.

Tech

Dynamic Multi-Level Loading in GDevelop (Without Duplicating Scenes)

If you’re building a multi-level game in GDevelop, you do not need a separate scene for every stage. There’s a pattern using global variables and external layouts that keeps your entire game running on a single reusable scene. Here’s how it works at a high level. One global variable drives everything. Create a number variable called current_level in your project’s global variables. Initialize it…

In GDevelop, developers need not create a unique scene for every stage in a multi-level game. A technique leveraging global variables and external layouts allows the entire game to operate within a single adaptable scene. This approach begins with a global variable, named current_level, which serves as the level indicator. It is initialized to 1 in the project's global variables, acting as a level pointer throughout the game.

Instead of generating new scenes for each level, external layouts named in a consistent pattern are utilized — Level1, Level2, Level3, and so forth. Each layout inherits from the main game scene, thereby gaining access to all existing objects. The core of dynamic level loading occurs at the scene commencement. In the main scene's event sheet, an event titled "Beginning of scene" is added, employing the action "Create objects from external layout."

The layout name follows an expression format: "Level" concatenated with the value of the global variable current_level. This action ensures that the scene starts with the appropriate layout based on the current level.

Once the scene initializes, a Trigger Once condition is implemented to prevent the event from executing repeatedly each frame. This action effectively transitions to the next level when the player interacts with a door, increments the current_level variable by 1, and reloads the scene. By employing this method, when the player collides with a door and presses the interact key, the scene restarts, runs the beginning-of-scene event, and automatically loads the next layout as dictated by the updated current_level value.

However, developers must account for varying level sizes and camera boundaries to maintain player focus within the appropriate viewport. If levels differ in size, per-level camera boundary logic must be programmed to adjust camera boundaries according to the current_level variable. Neglecting this could result in the camera drifting off-screen to empty space, disrupting the gameplay experience.

This method of game development shines in its scalability. For instance, projects with over 20 levels have been managed effectively without the need for duplicated event sheets or scattering objects across multiple scenes. The entire game remains organized within a single scene, simplifying management and reducing complexity. For a step-by-step visual guide on implementing this technique, a comprehensive video walkthrough is available at https://youtu.be/KBtNvKsRlwk.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Aprendiendo a soltar: volví a programar después de dos años y todo había cambiado

Permítanme presentarme primero, de tal manera que puedan entender lo que siento. Me gradué como ingeniero informático en agosto de 2025, pero en realidad tengo desde diciembre de 2024 de no escribir…

  • Graduated as software engineer in August 2025
  • University focused on vanilla languages, ignored frameworks
  • Recognized AI's importance in modern programming

Every Step Runs Inside poll(): The Kafka Consumer Flow, End to End

Every Kafka consumer application calls poll() . Very few developers can list what happens inside it. That gap shows up at the worst time: a consumer that hangs, a group that rebalances in a loop, a…

  • First step, consumer asks bootstrap broker for group coordination broker.
  • Poll() function drives entire consumer flow, looping between fetch and commit steps.

More from Wednesday 21 October →