Beep8 logo

Tilemap Documentation

Tilemap Documentation Source Code

Tilemap Methods

beep8.Tilemap.convertFromText(mapText)

Get a text map and convert it to an array of arrays.

Parameters

  • mapText (string): The text map to convert.

Returns

  • (Array): The converted tilemap array.

beep8.Tilemap.createEmptyTilemap(width, height)

Create an empty tilemap array of the specified size.

Parameters

  • width (number): The width of the tilemap.
  • height (number): The height of the tilemap.

Returns

  • (Array): The empty tilemap array.

beep8.Tilemap.createFromArray(grid, tilePattern)

Create a tilemap from an array of arrays. The tilePattern is an object that maps tile characters to tile properties.

Parameters

  • grid (Array): The grid array to create the tilemap from.
  • tilePattern (Object): The tile pattern object.

Returns

  • (Array): The created tilemap array.

beep8.Tilemap.draw(tilemap [,width] [,height])

Draw a tilemap array to the screen.

Parameters

  • tilemap (Array): The tilemap array to draw.
  • [width] (number): The width of the tilemap to draw. (default: null)
  • [height] (number): The height of the tilemap to draw. (default: null)

beep8.Tilemap.getDefaultTile()

Get the default tile for a tilemap.

Returns

  • (Array): The default tile.

beep8.Tilemap.load(data)

Load a tilemap array from a string.

Parameters

  • data (string): The encoded string

Returns

  • (Array): The tilemap array

beep8.Tilemap.resize(tilemap, width, height)

Resize a tilemap array to the specified width and height.

Parameters

  • tilemap (Array): The tilemap array to resize.
  • width (number): The new width of the tilemap.
  • height (number): The new height of the tilemap.

Returns

  • (Array): The resized tilemap array.

beep8.Tilemap.save(tilemap)

Convert a tilemap array to a string.

This string can be loaded with beep8.Tilemap.load.

Parameters

  • tilemap (Array): The tilemap array to save.

Returns

  • (string): The encoded string

beep8.Tilemap.shift(tilemap, dx, dy)

Shift and wrap a tilemap array by the specified amount.

Parameters

  • tilemap (Array): The tilemap array to shift.
  • dx (number): The amount to shift the tilemap in the x direction.
  • dy (number): The amount to shift the tilemap in the y direction.

beep8.Tilemap.wallTile(x, y, grid, name)

Select a wall tile from a predefined list based on the surrounding tiles. The grid is the 2D array of tile ids. The x and y are the coordinates of the tile to check.

Parameters

  • x (number): The x coordinate of the tile.
  • y (number): The y coordinate of the tile.
  • grid (Array): The 2D array of tile ids.
  • name (string): The name of the wall tile to select. Picked from the default lists of wall patterns.

Returns

  • (number): The selected wall tile id.

More Beep8 Docs

Actors Documentation

Async Documentation

Core Functions

Input Documentation

App Intro Documentation

Joystick Documentation

Menu Documentation

Music Documentation

Particle System Documentation

Passcodes Documentation

Public API

Random Numbers Documentation

Scene Documentation

SFX Documentation

Text Renderer

Tilemap Documentation

Utilities Documentation