Skip to content

Commit

Permalink
Adds tilemap functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Oct 21, 2023
1 parent f211b26 commit 2ead102
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions 5.7/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [INI](ini)
- [GML](gml)
- [Grids & 2D Arrays](grids-and-arrays)
- [Tilemaps](tilemaps)
- [VDF](vdf)
- [QML](qml)
- [Utilities](utilities)
49 changes: 49 additions & 0 deletions 5.7/tilemaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Tilemaps

 

## `SnapBufferWriteTilemap`

*Returns:* N/A (`undefined`)

|Name |Datatype|Purpose |
|---------|--------|-----------------------------|
|`buffer` |buffer |Buffer to write the data into|
|`tilemap`|tilemap |Tilemap to serialize |

Stores the contents of a tilemap in a buffer, starting at the buffer's current head position.

!> The name of the tileset to use is embedded in the tilemap data so any renamed or deleted tilesets will fail to read.

 

## `SnapBufferReadTilemapNew`

*Returns:* N/A (`undefined`)

|Name |Datatype|Purpose |
|--------|--------|---------------------------------------------------------------------------------------------------------------------------------------------------|
|`buffer`|buffer |Buffer to write the data into |
|`offset`|integer |The position in the buffer to read the tilemap from, relative to the start of the buffer. If set to `undefined`, the buffer's head position is used|
|`layer` |string |Name of room layer to create the tilemap on |

Creates a new tilemap on the given layer. The tilemap's dimensions and position will be set to whatever is in the data found in the buffer.

!> The name of the tileset to use is embedded in the tilemap data (see above) so any renamed or deleted tilesets will fail to read.

 

## `SnapBufferReadTilemapOverwrite`

*Returns:* N/A (`undefined`)

|Name |Datatype|Purpose |
|----------------|--------|---------------------------------------------------------------------------------------------------------------------------------------------------|
|`buffer` |buffer |Buffer to write the data into |
|`offset` |integer |The position in the buffer to read the tilemap from, relative to the start of the buffer. If set to `undefined`, the buffer's head position is used|
|`tilemap` |tilemap |Tilemap whose contents this function should overwrite |
|`[readPosition]`|boolean |Whether to set the position of the tilemap based on the coordinates in the tilemap data. Defaults to `false` if not specified |

Overwrites the contents of an already existing tilemap based on data serialized by `SnapBufferWriteTilemap()`. If the width or height of the incoming tilemap is larger than the current tilemap, extra tiles will not be created. If the width or height is smaller than the current tilemap, the empty space will be set to `0` (no tile).

!> The name of the tileset to use is embedded in the tilemap data (see above) so any renamed or deleted tilesets will fail to read.

0 comments on commit 2ead102

Please sign in to comment.