Godot Mapcrafter

Generate a map for your Godot game with ease.

Basic Map Functions - the bread and butter of 2D Array manipulation

What do these functions do:

These functions help perform basic tasks with checking/saftey and deal with getting information

When do you use these functions?

Almost all the time

Set Cell

This function sets a cell's value in the map, ensuring the coordinates are within bounds.

  • setCell(x:int, y:int, cellToSet:int, map:Array) -> Array
    • x

      : The x-coordinate of the cell to set.

    • y

      : The y-coordinate of the cell to set.

    • cellToSet

      : The value to set the cell to.

    • map

      : The 2D array representing the map.

  • Example GIF: A cell being set on a map.

    A cell being set on a map.

  • Get Cell

    This function retrieves the value of a cell at a specific coordinate in the map.

  • getCell(x:int, y:int, map:Array) -> int
    • x

      : The x-coordinate of the cell to retrieve.

    • y

      : The y-coordinate of the cell to retrieve.

    • map

      : The 2D array representing the map.

  • Example GIF: Retrieving a cell value from a map.

    Retrieving a cell value from a map.

  • Get Random Tile Type

    This function returns a random tile type from an array of possible tiles.

  • getRandomTileType(arrOfPossibleTiles:Array) -> int
    • arrOfPossibleTiles

      : An array of possible tile types.

  • Get Map Height and Width

    This function returns the height and width of the map.

  • getMapHeightAndWidth(map:Array) -> Array
    • map

      : The 2D array representing the map.

  • Example GIF: Getting the dimensions of a map.

    Getting the dimensions of a map.

  • Get Halfway of Length

    This function calculates and returns the halfway point of a given length.

  • getHalfWayOfLength(width:int) -> int
    • width

      : The length for which to find the halfway point.

  • Example GIF: Calculating the halfway point of a given length.

    Calculating the halfway point of a given length.

  • Get a Random Point in Map

    This function returns a random point within the map.

  • getARandomPointInMap(map:Array) -> Vector2i
    • map

      : The 2D array representing the map.

  • Example GIF: Selecting a random point on a map.

    Selecting a random point on a map.

  • Get a Random Tile by Tile Type

    This function returns a random tile of a specified type from the map.

  • getARandomTileByTileType(tileToGet:int, map:Array) -> Vector2
    • tileToGet

      : The tile type to search for in the map.

    • map

      : The 2D array representing the map.

  • Example GIF: Selecting a random tile of a specific type from the map.

    Selecting a random tile of a specific type from the map.

  • Get Array of All Tiles of One Type

    This function returns an array of all tiles of a specified type in the map.

  • getArrayOfAllTilesOfOneType(tileToGet:int, map:Array) -> Array
    • tileToGet

      : The tile type to search for in the map.

    • map

      : The 2D array representing the map.

  • Example GIF: Retrieving all tiles of a specific type from the map.

    Retrieving all tiles of a specific type from the map.

  • Set Fast Noise Lite Seed

    This function sets the seed for the FastNoiseLite generator.

  • setFastNoiseLiteSeed(_seed:int) -> void
    • _seed

      : The seed value to set for the noise generator.

  • Calculate Distance Between Two Points

    This function calculates the Euclidean distance between two points.

  • distance(p1: Vector2, p2: Vector2) -> float
    • p1

      : The first point as a Vector2.

    • p2

      : The second point as a Vector2.

  • Example GIF: Calculating the distance between two points on a map.

    Calculating the distance between two points on a map.

  • Map Generation Functions - functions to make 2D Arrays

    What do these functions do:

    These functions help set out a base map given a proper HEIGHT and WIDTH sometimes optional parameters can be passed in such as column_thickness or boxWidth for various extra functions in base map generation.

    When do you use these functions?

    Whenever you start the process of making a map

    Generate Blank Map

    This function generates a 2D array given the HEIGHT and WEIGHT passed in

  • generateBlankMap(width: int, height: int, cellToSetWith: int) -> Array
    • width

      : The width of the map to be generated

    • height

      : The height of the map to be generated

    • cellToSetWith

      : The cell type to set the map with

  • Example GIF: A series of blank maps being generated

    A series of blank maps being generated

  • Generate Random Map

    This function generates a 2D array given the HEIGHT and WEIGHT passed in, while adding random tiles

  • generateRandomMap(width: int, height: int, tile_type1: int, tile_type2: int, threshold: float) -> Array
    • width

      : The width of the map to be generated

    • height

      : The height of the map to be generated

    • tile_type1

      : The tile to set the tile type with

    • tile_type2

      : The tile type to set the tile with

    • threshold

      : The chance of the tile to be set

  • Example GIF:

  • Generate Bordered Map

    This function generates a 2D array given the HEIGHT and WEIGHT passed in, while adding a standard uniform square border around the 2D Array of a given tile type (in most cases, the wall tile)

  • generateBorderedMap(width: int, height: int, border_tile: int, inner_tile: int, border_thickness: int = 1) -> Array
    • width

      : The width of the map to be generated

    • height

      : The height of the map to be generated

    • border_tile

      : The tile type to set the border with

    • inner_tile

      : The tile type to set the inner map with

    • border_thickness

      : The thickness of the border to be set

  • Example GIF: A series of maps being generated with various wall thicknesses

    A series of maps being generated with various wall thicknesses

  • Generate Row Map

    This function generates a 2D array given the HEIGHT and WEIGHT passed in, while adding rows of different tiles

  • generateRowMap(width: int, height: int, tile_type1: int, tile_type2: int, row_thickness: int) -> Array
    • width

      : The width of the map to be generated

    • height

      : The height of the map to be generated

    • tile_type1

      : The row to set the tile type with

    • tile_type2

      : The tile type to set the row with

    • row_thickness

      : The thickness of the row to be set

  • Example GIF:

  • Generate Column Map

    This function generates a 2D array given the HEIGHT and WEIGHT passed in, while adding columns of different tiles

  • generateColumnMap(width: int, height: int, tile_type1: int, tile_type2: int, column_thickness: int) -> Array
    • width

      : The width of the map to be generated

    • height

      : The height of the map to be generated

    • tile_type1

      : The column to set the tile type with

    • tile_type2

      : The tile type to set the column with

    • column_thickness

      : The thickness of the column to be set

  • Example GIF:

  • Generate Diagonal Stripes Map

    This function generates a 2D array given the HEIGHT and WEIGHT passed in, while adding diagonal stripes of different tiles

  • generateDiagonalStripesMap(width: int, height: int, tile_type1: int, tile_type2: int, stripe_width: int = 1, reverse_direction: bool = false) -> Array
    • width

      : The width of the map to be generated

    • height

      : The height of the map to be generated

    • tile_type1

      : The stripe to set the tile type with

    • tile_type2

      : The tile type to set the stripe with

    • stripe_thickness

      : The thickness of the stripe to be set

    • reverse_direction

      : The direction of the stripe to be set

  • Example GIF:

  • Generate Checkerboard Map

    This function generates a 2D array given the HEIGHT and WEIGHT passed in, while adding a checkerboard pattern of different tiles

  • generateCheckerboardMap(width: int, height: int, tile_type1: int, tile_type2: int, square_size: int) -> Array
    • width

      : The width of the map to be generated

    • height

      : The height of the map to be generated

    • tile_type1

      : The tile to set the tile type with

    • tile_type2

      : The tile type to set the tile with

    • square_size

      : The size of the square to be set

  • Example GIF:

  • Generate Map With Box

    This function generates a 2D array given the HEIGHT and WEIGHT passed in, while adding a box of different tiles

  • generateMapWithBox(width: int, height: int, mapTile: int, boxTile: int, topLeftPosOfBox: Vector2, boxWidth: int, boxHeight: int) -> Array
    • width

      : The width of the map to be generated

    • height

      : The height of the map to be generated

    • mapTile

      : The box to set the tile type with

    • boxTile

      : The tile type to set the box with

    • topLeftPosOfBox

      : The top left position of the box to be set

    • boxHeight

      : The height of the box to be set

    • boxWidth

      : The width of the box to be set

  • Example GIF:

  • Generate Cave Map

    This function generates a 2D array given the HEIGHT and WEIGHT passed in, while adding a cave-like pattern of different tiles

  • generateCaveMap(width: int, height: int, wall_tile: int, floor_tile: int, initial_chance: float = 0.45, iterations: int = 4) -> Array
    • width

      : The width of the map to be generated

    • height

      : The height of the map to be generated

    • wall_tile

      : The tile to set the wall with

    • floor_tile

      : The tile type to set the floor with

    • initial_chance

      : The initial chance of the wall to be set

    • iterations

      : The number of iterations of the cellular automoata algorithim (conway's game of life)

  • Example GIF:

  • Map Modification Functions - functions to manipulate 2D Arrays

    What do these functions do:

    These functions modify the current map, often taking data from the map and applying it back to the map in some mathermical or random way

    When do you use these functions?

    Up to creative liberty

    Apply Random Cells to Certain Cell Type

    This function applies a specified cell type randomly to the map based on a given chance.

  • applyRandomCellsToCertainCellType(randomChance:float, cellToSet:int, map:Array) -> Array
    • randomChance

      : The probability of setting a cell to the specified type.

    • cellToSet

      : The cell type to apply to the map.

    • map

      : The 2D array representing the map.

  • Example GIF: Random cells being applied to a map.

    Random cells being applied to a map.

  • Apply Radial Symmetry

    This function applies radial symmetry to a 2D map, reflecting tiles across both axes. (Working on adding a boolean to select bottom left, top or bottom right, at the moment it is only top left)

  • applyRadialSymmetry(map: Array) -> Array
    • map

      : The 2D array representing the map.

  • Example GIF: A map being modified to have radial symmetry.

    A map being modified to have radial symmetry.

  • Apply Mirror Vertical

    This function mirrors the map vertically, reflecting tiles across the vertical axis.

  • applyMirrorVertical(map: Array, flipFromLeftToRight:bool=true) -> Array
    • map

      : The 2D array representing the map.

    • flipFromLeftToRight

      : Whether to mirror from left to right or right to left.

  • Example GIF: A map being mirrored vertically.

    A map being mirrored vertically.

  • Apply Mirror Horizontal

    This function mirrors the map horizontally, reflecting tiles across the horizontal axis.

  • applyMirrorHorizontal(map: Array, flipFromTopToBottom: bool=true) -> Array
    • map

      : The 2D array representing the map.

    • flipFromTopToBottom

      : Whether to mirror from top to bottom or bottom to top.

  • Example GIF: A map being mirrored horizontally.

    A map being mirrored horizontally.

  • Apply Cellular Noise

    This function applies cellular noise to the map to generate organic-looking patterns.

  • applyCellularNoise(freqVal:float, thresholdValue:float, cellToSet:int, map:Array) -> Array
    • freqVal

      : The frequency value for the noise generation.

    • thresholdValue

      : The threshold value for determining when to set a cell.

    • cellToSet

      : The cell type to apply based on the noise.

    • map

      : The 2D array representing the map.

  • Example GIF: A map being modified using cellular noise.

    A map being modified using cellular noise.

  • Apply Fast Perlin Noise

    This function applies Perlin noise to the map to generate smooth, natural-looking terrain.

  • applyFastPerlinNoise(freqVal:float, thresholdValue:float, cellToSet:int, map:Array) -> Array
    • freqVal

      : The frequency value for the Perlin noise.

    • thresholdValue

      : The threshold value for determining when to set a cell.

    • cellToSet

      : The cell type to apply based on the noise.

    • map

      : The 2D array representing the map.

  • Example GIF: A map being generated using Perlin noise.

    A map being generated using Perlin noise.

  • Apply Fast Value Noise

    This function applies value noise to the map for creating varied terrain features.

  • applyFastValueNoise(freqVal:float, thresholdValue:float, cellToSet:int, map:Array) -> Array
    • freqVal

      : The frequency value for the value noise.

    • thresholdValue

      : The threshold value for determining when to set a cell.

    • cellToSet

      : The cell type to apply based on the noise.

    • map

      : The 2D array representing the map.

  • Example GIF: A map being generated using value noise.

    A map being generated using value noise.

  • Apply Fast Worley Noise

    This function applies Worley noise to create cellular-like patterns in the map.

  • applyFastWorleyNoise(tileToSet: int, noise_scale: float, threshold: float, map:Array) -> Array
    • tileToSet

      : The cell type to set based on the noise.

    • noise_scale

      : The scale of the Worley noise.

    • threshold

      : The threshold value for determining when to set a cell.

    • map

      : The 2D array representing the map.

  • Example GIF: A map being generated using Worley noise.

    A map being generated using Worley noise.

  • Apply Cellular Automata

    This function applies cellular automata rules, such as Conway's Game of Life, to evolve the map over several generations.

  • applyCellularAutomata(generations: int, cellToApplyWith:int, cellToBlankWith:int, map: Array) -> Array
    • generations

      : The number of iterations to apply the automata rules.

    • cellToApplyWith

      : The cell type to use for alive cells.

    • cellToBlankWith

      : The cell type to use for dead cells.

    • map

      : The 2D array representing the map.

  • Example GIF: A map being evolved using cellular automata.

    A map being evolved using cellular automata.

  • Apply Erosion

    This function simulates erosion by gradually changing certain cells based on their neighbors.

  • applyErosion(iterations: int, cellToApplyWith:int, cellToGetRidOf:int, map: Array) -> Array
    • iterations

      : The number of erosion cycles to apply.

    • cellToApplyWith

      : The cell type to apply during erosion.

    • cellToGetRidOf

      : The cell type to be eroded away.

    • map

      : The 2D array representing the map.

  • Example GIF: A map undergoing erosion.

    A map undergoing erosion.

  • Apply Specific Tile to a Random Set of Tiles

    This function randomly selects a set of tiles on the map and applies a specific tile type to them.

  • applySpecificTileToARandomSetOfTiles(tileToApply: int, count: int, map: Array) -> Array
    • tileToApply

      : The tile type to apply.

    • count

      : The number of tiles to apply the tile type to.

    • map

      : The 2D array representing the map.

  • Example GIF: Applying a specific tile to a random set of tiles on the map.

    Applying a specific tile to a random set of tiles on the map.

  • Apply Expanded Tiles

    This function expands a given tile type by a specified range in all directions.

  • applyExpandedTiles(tileToExpand: int, range: int, map: Array) -> Array
    • tileToExpand

      : The tile type to expand.

    • range

      : The range by which to expand the tile type.

    • map

      : The 2D array representing the map.

  • Example GIF: Expanding tiles on a map.

    Expanding tiles on a map.

  • Apply Conway's Game of Life

    This function applies Conway's Game of Life rules to the map, simulating cellular automata evolution.

  • applyConwaysGameOfLife(map: Array, aliveTile: int, deadTile: int, generations: int) -> Array
    • map

      : The 2D array representing the map.

    • aliveTile

      : The tile type representing live cells.

    • deadTile

      : The tile type representing dead cells.

    • generations

      : The number of generations to simulate.

  • Example GIF: Applying Conway's Game of Life rules to a map.

    Applying Conway's Game of Life rules to a map.

  • Apply Connections to All Sections

    This function connects all sections in the map using the shortest possible path.

  • applyConnectionsToAllSections(map: Array, connectionTile: int) -> Array
    • map

      : The 2D array representing the map.

    • connectionTile

      : The tile type to use for connections.

  • Example GIF: Connecting all sections on a map.

    Connecting all sections on a map.

  • Apply Connection to Closest Sections

    This function connects the closest sections in the map using the shortest possible path.

  • applyConnectionToClosestSections(map: Array, connectionTile: int) -> Array
    • map

      : The 2D array representing the map.

    • connectionTile

      : The tile type to use for connections.

  • Example GIF: Connecting the closest sections on a map.

    Connecting the closest sections on a map.

  • Apply Linear Connection to Sections

    This function creates linear connections between sections in the map.

  • applyLinearConnectionToSections(map: Array, connectionTile: int) -> Array
    • map

      : The 2D array representing the map.

    • connectionTile

      : The tile type to use for connections.

  • Example GIF: Creating linear connections between sections on a map.

    Creating linear connections between sections on a map.

  • Apply Connection with Minimum Spanning Tree (MST)

    This function connects all sections using the Minimum Spanning Tree algorithm.

  • applyConnectionWithMST(map: Array, connectionTile: int) -> Array
    • map

      : The 2D array representing the map.

    • connectionTile

      : The tile type to use for connections.

  • Example GIF: Connecting sections using the Minimum Spanning Tree algorithm.

    Connecting sections using the Minimum Spanning Tree algorithm.

  • Apply Connections with Random Walks

    This function connects sections using random walks, creating more organic paths.

  • applyConnectionsWithRandomWalks(map: Array, connectionTile: int, walkCount: int) -> Array
    • map

      : The 2D array representing the map.

    • connectionTile

      : The tile type to use for connections.

    • walkCount

      : The number of random walks to perform.

  • Example GIF: Connecting sections using random walks on a map.

    Connecting sections using random walks on a map.

  • Apply Connections Linearly

    This function connects sections linearly in a specified order.

  • applyConnectionsLinearly(map: Array, connectionTile: int, order: Array) -> Array
    • map

      : The 2D array representing the map.

    • connectionTile

      : The tile type to use for connections.

    • order

      : The order in which to connect the sections.

  • Example GIF: Connecting sections linearly on a map.

    Connecting sections linearly on a map.

  • Map Mutation Functions - functions to mutate/draw what is already inside your 2D Array

    What do these functions do:

    These functions apply various transformations or drawing algorithms to an existing map to enhance or modify it.

    When do you use these functions?

    Use these when you need to apply specific transformations to a base map.

    Draw Line

    This function draws a line between two points on the map with a specified thickness.

  • drawLine(startPoint:Vector2i, endPoint:Vector2i, lineSize:int, stepsToTake:int, cellToSet:int, map:Array) -> Array
    • startPoint

      : The starting point of the line.

    • endPoint

      : The end point of the line.

    • lineSize

      : The thickness of the line.

    • stepsToTake

      : The number of steps to take when drawing the line.

    • cellToSet

      : The cell type to set along the line.

    • map

      : The 2D array representing the map.

  • Example GIF: Drawing a line on a map with specified thickness.

    Drawing a line on a map with specified thickness.

  • Draw Box

    This function draws a box at a specified position with a given size.

  • drawBox(startPoint:Vector2i, size:int, cellToSet:int, map:Array) -> Array
    • startPoint

      : The top-left corner of the box.

    • size

      : The size of the box.

    • cellToSet

      : The cell type to set within the box.

    • map

      : The 2D array representing the map.

  • Example GIF: Drawing a box on a map.

    Drawing a box on a map.

  • Draw Border

    This function draws a border around the map with a specified thickness.

  • drawBorder(border_size: int, cellToSet: int, map: Array) -> Array
    • border_size

      : The thickness of the border.

    • cellToSet

      : The cell type to set for the border.

    • map

      : The 2D array representing the map.

  • Example GIF: Drawing a border around a map.

    Drawing a border around a map.

  • Draw Random Walk

    This function performs a random walk starting from a specified position, with a given thickness.

  • drawRandomWalk(startPos: Vector2i, steps: int, cellToSet: int, thickness: int, map: Array) -> Array
    • startPos

      : The starting position of the random walk.

    • steps

      : The number of steps to take.

    • cellToSet

      : The cell type to set along the walk.

    • thickness

      : The thickness of the walk.

    • map

      : The 2D array representing the map.

  • Example GIF: Performing a random walk on a map.

    Performing a random walk on a map.

  • Draw Circle

    This function draws a circle on the map at a specified center with a given radius.

  • drawCircle(centerOfCircle: Vector2, radius: int, cellToSet: int,map: Array) -> Array
    • centerOfCircle

      : The center of the circle.

    • radius

      : The radius of the circle.

    • cellToSet

      : The cell type to set within the circle.

    • map

      : The 2D array representing the map.

  • Example GIF: Drawing a circle on a map.

    Drawing a circle on a map.

  • Draw Square

    This function draws a square on the map at a specified top-left position with a given size.

  • drawSquare(top_left: Vector2, size: int, cellToSet: int, map: Array) -> Array
    • top_left

      : The top-left corner of the square.

    • size

      : The size of the square.

    • cellToSet

      : The cell type to set within the square.

    • map

      : The 2D array representing the map.

  • Example GIF: Drawing a square on a map.

    Drawing a square on a map.

  • Draw Square Every Nth Tiles

    This function draws squares on the map at regular intervals, with specified padding and size.

  • drawSquareEveryNthTiles(square_size: int, every_x_tiles: int, padding: int, cellToSet: int, map: Array) -> Array
    • square_size

      : The size of the squares to draw.

    • every_x_tiles

      : The interval at which to draw the squares.

    • padding

      : The padding to apply around each square.

    • cellToSet

      : The cell type to set within the squares.

    • map

      : The 2D array representing the map.

  • Draw Corridor

    This function creates a corridor between two points with a specified width.

  • drawCorridor(start: Vector2, end: Vector2, tile_type: int, corridor_size: int, map: Array) -> Array
    • start

      : The starting point of the corridor.

    • end

      : The end point of the corridor.

    • tile_type

      : The cell type to set within the corridor.

    • corridor_size

      : The width of the corridor.

    • map

      : The 2D array representing the map.

  • Example GIF: Drawing a corridor between two points on a map.

    Drawing a corridor between two points on a map.

  • Draw to Fill in Patches of a Size by Tile Type

    This function fills in patches of a specified minimum size with a given tile type.

  • drawToFillInPatchesOfASizeByTileType(min_size: int, cellToCheck:int, cellToFillWith:int, map: Array) -> Array
    • min_size

      : The minimum size of patches to fill.

    • cellToCheck

      : The cell type to look for in the map.

    • cellToFillWith

      : The cell type to fill the patches with.

    • map

      : The 2D array representing the map.

  • Draw Random Walks Inside Large Sections of a Random Tile Type

    This function performs multiple random walks inside large sections of a specific tile type.

  • drawRandomWalksInsideLargeSectionsOfARandomTileType(timesToPlaceAWalk:int, walkCount:int, tileTypeOfSection:int, tileTypeToPlace:int, map:Array) -> Array
    • timesToPlaceAWalk

      : The number of random walks to perform.

    • walkCount

      : The number of steps each random walk should take.

    • tileTypeOfSection

      : The tile type of the section where random walks will occur.

    • tileTypeToPlace

      : The cell type to set during the random walks.

    • map

      : The 2D array representing the map.

  • Draw Crazy Sporadic Walk

    This function performs a sporadic walk with random direction changes and thickness, potentially teleporting to a new location.

  • drawCrazySporadicWalk(startPos: Vector2i, steps: int, cellToSet: int, thickness: int, map: Array) -> Array
    • startPos

      : The starting position of the sporadic walk.

    • steps

      : The number of steps to take.

    • cellToSet

      : The cell type to set during the walk.

    • thickness

      : The thickness of the walk.

    • map

      : The 2D array representing the map.

  • Example GIF: Performing a crazy sporadic walk on a map.

    Performing a crazy sporadic walk on a map.

  • Draw Non-Overlapping Walk

    This function performs a non-overlapping walk on the map, ensuring no overlap with previous steps.

  • drawNonOverlappingWalk(startPos: Vector2i, steps: int, cellToSet: int, square_size: int, map: Array) -> Array
    • startPos

      : The starting position of the walk.

    • steps

      : The number of steps to take.

    • cellToSet

      : The cell type to set during the walk.

    • square_size

      : The size of the square drawn during each step of the walk.

    • map

      : The 2D array representing the map.

  • Example GIF: Performing a non-overlapping walk on a map.

    Performing a non-overlapping walk on a map.

  • Draw Natural Border

    This function creates a natural-looking border around the map with varying thickness.

  • drawNaturalBorder(min_wall_thickness: int, max_wall_thickness: int, wall_tile: int, map: Array) -> Array
    • min_wall_thickness

      : The minimum thickness of the wall.

    • max_wall_thickness

      : The maximum thickness of the wall.

    • wall_tile

      : The cell type to set for the wall.

    • map

      : The 2D array representing the map.

  • Example GIF: Creating a natural-looking border around a map.

    Creating a natural-looking border around a map.

  • Map Section Functions - helps partition map into sections held in linear arrays

    What do these functions do:

    These functions deal with sections of the map, helping you identify, manipulate, or calculate properties related to map sections.

    When do you use these functions?

    Use these when working with specific sections of the map, such as identifying regions or connecting sections.

    Get Sections

    This function returns all contiguous sections in the map, where each section consists of tiles of the same type.

  • getSections(map: Array) -> Array
    • map

      : The 2D array representing the map.

  • Get Sections of a Certain Tile

    This function returns all contiguous sections in the map that consist of a specific tile type.

  • getSectionsOfACertainTile(tile_type: int, map: Array) -> Array
    • tile_type

      : The tile type to identify sections for.

    • map

      : The 2D array representing the map.

  • Get a Random Section

    This function returns a random section from a list of sections.

  • getARandomSection(sections: Array, map: Array) -> Array
    • sections

      : An array of sections to choose from.

    • map

      : The 2D array representing the map.

  • Get a Random Section by Tile

    This function returns a random section from the map that consists of a specific tile type.

  • getARandomSectionByTile(cellToGetSelectionOf: int, map: Array) -> Array
    • cellToGetSelectionOf

      : The tile type to identify sections for.

    • map

      : The 2D array representing the map.

  • Get Largest Section of Tile Type

    This function returns the largest contiguous section in the map that consists of a specific tile type.

  • getLargestSectionOfTileType(tile_type: int, map: Array) -> Array
    • tile_type

      : The tile type to identify the largest section for.

    • map

      : The 2D array representing the map.

  • Find Center Tile Given a Section

    This function calculates and returns the center tile of a given section.

  • findCenterTileGivenASection(section: Array) -> Vector2
    • section

      : The section of tiles to find the center for.

  • Check and Connect Sections of a Certain Tile

    This function checks if all sections of a certain tile type are connected and connects them if they are not.

  • checkAndConnectIfAllSectionsOfACertainTileAreConnected(tileToCheck: int, mapToCheck: Array) -> Array
    • tileToCheck

      : The tile type to check and connect sections for.

    • mapToCheck

      : The 2D array representing the map.

  • Closest Points Between Sections

    This function calculates the closest points between two sections and returns them.

  • closestPointsBetweenSections(section1: Array, section2: Array) -> Array
    • section1

      : The first section of tiles.

    • section2

      : The second section of tiles.

  • Calculate Centroid

    This function calculates the centroid (geometric center) of a section of tiles.

  • calculateCentroid(section: Array) -> Vector2
    • section

      : The section of tiles to calculate the centroid for.

  • Total Distance

    This function calculates the total distance between all pairs of selected points.

  • totalDistance(selected_points: Array) -> float
    • selected_points

      : An array of selected points to calculate the distance between.

  • Find Smallest Square

    This function finds the smallest square that can enclose a set of points.

  • findSmallestSquare(points: Array) -> Array
    • points

      : An array of points to find the smallest enclosing square for.

  • Find Most Distant Points

    This function finds the most distant points in a section using Farthest Point Sampling.

  • findMostDistantPoints(section: Array, numPoints: int) -> Array
    • section

      : The section of tiles to sample points from.

    • numPoints

      : The number of distant points to find.

  • Minimum Distance to Wall

    This function calculates the minimum distance from a point to any wall in the map.

  • minDistanceToWall(point: Vector2, walls: Array) -> float
    • point

      : The point to calculate the distance from.

    • walls

      : An array of wall tiles to calculate the distance to.

  • Find Most Distant Points with Padding from Wall

    This function finds the most distant points in a section, ensuring they are not too close to walls.

  • findMostDistantPointsWithPaddingFromWall(section: Array, walls: Array, num_points: int, min_dist_from_wall: float) -> Array
    • section

      : The section of tiles to sample points from.

    • walls

      : An array of wall tiles to maintain distance from.

    • num_points

      : The number of distant points to find.

    • min_dist_from_wall

      : The minimum distance the points should be from any wall.

  • Connect Closest Sections

    This function connects the closest sections of a specific tile type by drawing corridors between them.

  • connectClosestSections(tile_type: int, connection_tile: int, map: Array) -> Array
    • tile_type

      : The tile type of the sections to connect.

    • connection_tile

      : The tile type to use for the connecting corridors.

    • map

      : The 2D array representing the map.

  • Advanced Map Functions - returns advanced information about the 2D Array (most likely not used by user)

    What do these functions do:

    These functions provide advanced operations or calculations on the map, such as counting tile occurrences or applying smoothing algorithms.

    When do you use these functions?

    Use these when you need to perform more complex map operations or analysis.

    Smooth and Remove Debris

    This function smooths the map by removing small sections of debris tiles and replacing them with a specified tile.

  • smoothAndRemoveDebris(map: Array, debris_tile: int, replacement_tile: int, debris_threshold: int) -> Array
    • map

      : The 2D array representing the map.

    • debris_tile

      : The tile type representing debris to remove.

    • replacement_tile

      : The tile type to replace debris with.

    • debris_threshold

      : The maximum size of debris sections to remove.

  • Example GIF: Smoothing a map and removing debris.

    Smoothing a map and removing debris.

  • Count Tiles

    This function counts the occurrences of each tile type in the map and returns a dictionary.

  • countTiles(map: Array) -> Dictionary
    • map

      : The 2D array representing the map.

  • Mark Visited

    This function marks tiles as visited in the map, useful for pathfinding and exploration algorithms.

  • markVisited(x: int, y: int, map: Array, visitedTile: int) -> Array
    • x

      : The x-coordinate of the tile to mark as visited.

    • y

      : The y-coordinate of the tile to mark as visited.

    • map

      : The 2D array representing the map.

    • visitedTile

      : The tile type used to mark the tile as visited.

  • Count Specific Tile

    This function counts the occurrences of a specific tile type in the map.

  • countSpecificTile(tileToCheck:int, map:Array) -> int
    • tileToCheck

      : The tile type to count.

    • map

      : The 2D array representing the map.

  • Get Percent of Tiles

    This function calculates the percentage of a specific tile type in the map.

  • getPercentOfTiles(tileToCheck:int, map:Array) -> float
    • tileToCheck

      : The tile type to calculate the percentage for.

    • map

      : The 2D array representing the map.

  • Get Least Common Tile

    This function returns the tile type with the least occurrences in the map.

  • getLeastCommonTile(map: Array) -> int
    • map

      : The 2D array representing the map.

  • Get All Tiles of Same Type with Flood Fill

    This function performs a flood fill to find all tiles of the same type starting from a given position.

  • getAllTilesOfSameTypeWithFloodFill(map: Array, start_pos: Vector2, tile_type: int, visited: Dictionary) -> Array
    • map

      : The 2D array representing the map.

    • start_pos

      : The starting position for the flood fill.

    • tile_type

      : The tile type to flood fill.

    • visited

      : A dictionary to track visited tiles.

  • Count Neighbors of Certain Cell Type

    This function counts the number of neighboring tiles of a specific type around a given position.

  • countNeighborsOfCertainCellType(x: int, y: int, cellToCheck:int, map: Array) -> int
    • x

      : The x-coordinate of the position to check.

    • y

      : The y-coordinate of the position to check.

    • cellToCheck

      : The tile type to count around the position.

    • map

      : The 2D array representing the map.

  • Identify Points of Interest on Map by Tile Type

    This function identifies and marks the center of each section of a specific tile type on the map.

  • identifyPointsOfInterestOnMapByTileType(tileToCheck:int,map:Array) -> Array
    • tileToCheck

      : The tile type to identify points of interest for.

    • map

      : The 2D array representing the map.

  • Apply Smoothing

    This function applies smoothing to the map by adjusting the tile types based on neighboring tiles.

  • applySmoothing(map: Array, wall_tile: int, floor_tile: int, smoothing_iterations: int = 1) -> Array
    • map

      : The 2D array representing the map.

    • wall_tile

      : The tile type representing walls.

    • floor_tile

      : The tile type representing floors.

    • smoothing_iterations

      : The number of smoothing iterations to apply.

  • Example GIF: Applying smoothing to a map to adjust tile types.

    Applying smoothing to a map to adjust tile types.