[BEHAVIOR] Necronomicron Procedural Maze

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Ball maze is a mobile game, where you have to win the maze.
  • Hey guys, how are you? I hope you're doing well...

    Today I was relaxing at home and checking out my plugins, which are a lot. I started looking at some I have for generating dungeons and mazes. While they work perfectly, they fail when it comes to setting up sprites or spawn points for enemies, bosses, lights, keys, and items. You practically have to guess where they'll go, and you end up doing a lot of programming, which really slows down the start of the level. So today I decided to design a plugin that procedurally generates your rogue-like maze and takes care of all that. You just have to tell it which sprite to use, and then you can decide whether to use it as a spawn point, an enemy, or whatever you want. I've included a demo, and if you want to see what it does and how it works, just ask.

    DEMO:https://necromaze.netlify.app/

    To review the mapping, use the mouse. Press F5 to regenerate the map. Enjoy.

  • Thanks for posting this, it seems really useful!

    I'm curious as to how it works, and whether something similar can be replicated and modified for different level types in a Construct 3 event sheet without plugins.

    Would you mind explaining how it generates mazes (and how it avoids overlapping structures, are arrays used & how, can the maze be changed later without breaking things, etc)?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for posting this, it seems really useful!

    I'm curious as to how it works, and whether something similar can be replicated and modified for different level types in a Construct 3 event sheet without plugins.

    Would you mind explaining how it generates mazes (and how it avoids overlapping structures, are arrays used & how, can the maze be changed later without breaking things, etc)?

    Well, I'm a Spanish speaker, although I'm proficient in technical English, some things are translated by Google Translate. So I hope you can understand it.

    Part 1: Technical Manual - ProceduralDungeon (SDK Plugin) The ProceduralDungeon plugin acts as an in-memory state manager that translates mathematical rules into a two-dimensional matrix (Grid), which is subsequently rendered in the Construct engine. 1. System Architecture Memory Grid: Uses a two-dimensional array (this.grid) to represent the map before it exists on screen. 0: Empty | 1: Floor | 2: Wall | 3: Corridor | 4: Door | 5: Secret Room. BSP (Binary Space Partitioning) Algorithm: Partitioning: Recursively divides the total map area into two smaller rectangles (sheets), provided they do not reach the defined minimum size (Min Room Size). Room: In each final "sheet," a random room smaller than the area of ​​the sheet is generated. Hallways: The center of the rooms is used to create L-shaped halls that connect the divided sheets. Entity Layer: The plugin stores the logical coordinates of enemies, chests, bosses, and lights in a this.entities object. This separates the logic (where things should go) from the instantiation (where the sprites are actually created). 2. Plugin Lifecycle Setup (Configuration): References to Construct 2 Sprite objects are registered. Generate (Calculation): The BSP is executed, the data in the this.grid array is populated, and the positions of entities are calculated in this.entities. Spawn (Display): The this.grid is traversed. If there is a "1", a "Floor" sprite is created at that x,y coordinate. The process is repeated for entities. Part 2: Replication Guide in Construct 3 (Native Events) In Construct 3, you don't have plugin .js files, so we will use the C3 Array Object to replicate the "Grid" logic and the Function system for BSP recursion. Project Preparation: Array Object: Create an Array object called DungeonMap (Width: Width, Height: Height, Depth: 1). Global Variables: MapWidth, MapHeight, MinRoomSize, MaxRoomSize, RoomCount. B. The BSP Algorithm (Recursion Simulation) Since we don't have a "Leaf class", we will create a Function that uses an Array as a "Stack" to process the divisions. SplitRoom(x, y, w, h) Function: Condition: If w > MaxRoomSize OR h > MaxRoomSize -> Proceed to divide. Action: Calculate splitX or splitY randomly. Action: Call the same SplitRoom function for the new zone A and zone B. If it is the final leaf: Generate room (draw 1s in the DungeonMap Array). C. Spawning System: To convert the array data into a game: Event: System: On Start of Layout. Action: System: Call Function "GenerateDungeon". Action: System: For "x" from 0 to MapWidth - 1. System: For "y" from 0 to MapHeight - 1. Condition: DungeonMap.At(loopindex("x"), loopindex("y")) = 1 (Floor). Action: System: Create object (Floor) at loopindex("x")*TileSize, loopindex("y")*TileSize. Condition: DungeonMap.At(loopindex("x"), loopindex("y")) = 2 (Wall). Action: System: Create object (Wall) at loopindex("x")*TileSize, loopindex("y")*TileSize. D. Dynamic Lighting System: C3 has a much simpler lighting engine than the Destination Out "hack" we use in the plugin: Lighting Layer: Create a layer called Light. Add the "Multiply" or "Dest. Out" effect (if you want holes) to this layer. Light Object: Create a blurred sprite. Effect: Apply the Additive effect (for color) or simply use the sprite to create the hole. In your spawn events, simply use: System: Create Object (Light) on the "Light" layer. For the "Reddish/Blue Touch": Light: Set Effect Param (0, Color_R, Color_G, Color_B). Note: C3 allows you to change the color of layer effects or sprites directly. Condition-Based Boss System: Instead of the plugin "guessing" when the boss appears, it uses C3's State Logic: Event: System: Every tick Condition: Sprite_Enemy: Count = 0 (This checks if there are no enemies left). Action: System: Set Global "BossActive" = 1. Event: System: On Global "BossActive" changed Condition: Global "BossActive" = 1 Action: System: Create Object (FinalBoss) on ExitX, ExitY. Migration Summary: C2 Plugin Construct 3 Equivalent this.grid (JS Array) Array Object (from C3) Leaf.split() (Recursion) Function (with loop or stack) this.entities (List) Object Variable or Family (Family is better in C3) JS Rendering System: For + Create Object

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)