|
| 1 | +# Level Data |
| 2 | + |
| 3 | +This file details the level data storage scheme. |
| 4 | + |
| 5 | +## Metadata |
| 6 | + |
| 7 | +This is the information that the level share uses to display levels: |
| 8 | + |
| 9 | +- `id:` - the id of the level |
| 10 | +- `public`- the visibility of the level, Boolean |
| 11 | +- `data` - the level data described below |
| 12 | +- `name` - the name of the level |
| 13 | +- `description` - a description of the level |
| 14 | +- `width` - the level width |
| 15 | +- `height` - the level height |
| 16 | +- `owner` - the id of the level owner |
| 17 | +- `tags` - a list of tags |
| 18 | +- `image_url` - currently doesn't do anything |
| 19 | +- `approvals` - how many people have rated this level thumbs up |
| 20 | +- `disapprovals` - how many people have rated this level thumbs down |
| 21 | +- `approval_percentage` - the percentage of people who have rated it thumbs up versus thumbs down |
| 22 | +- `total_plays` - how many times the level has been played |
| 23 | +- `finished_plays` - how many times the level has been finished |
| 24 | +- `owned` - is the user who requested this level the owner |
| 25 | +- `username` - the username of the owner |
| 26 | + |
| 27 | +## Level Data |
| 28 | + |
| 29 | +- `width` - the level width, max: 200, min: 10 |
| 30 | +- `height` - the level height, max: 100, min: 10 |
| 31 | +- `jumpHeight` - how far the player should jump in tiles |
| 32 | +- `wallJump` - what type of walljump the level should have, either `"none"`, `"off"`, or `"up"` |
| 33 | +- `bouncePadHeight` - the height in tiles the bounce pads should propel you |
| 34 | +- `zoom` - how many pixels should be used to display a block |
| 35 | +- `tilesetPath` - the path to the tileset |
| 36 | +- `layers` - an array of the different layers of the level |
| 37 | +- `spawn` an object with x and y properties showing where the player should spawn |
| 38 | +- `triggers` - a list of triggers in the level |
| 39 | + |
| 40 | +## Layers |
| 41 | + |
| 42 | +Each layer has a `"type"` property that determines what type of layer it is. There can only be one type of each layer. They also have a `data` property that stores the actual data of that layer in an array. |
| 43 | + |
| 44 | +## **RLE Encoding** |
| 45 | + |
| 46 | +RLE, or run length encoding compresses data by storing runs of numbers instead of each number individually. For example, instead of storing |
| 47 | + |
| 48 | +`[0, 0, 0, 0, 0, 5, 6, 1, 1, 1, 0]` |
| 49 | + |
| 50 | +RLE would encode that as: |
| 51 | + |
| 52 | +`[[0, 5], 5, 6, [1, 3], 0]` |
| 53 | + |
| 54 | +This takes a level down to about 4KB. |
| 55 | + |
| 56 | +**Layer Types** |
| 57 | + |
| 58 | +`"tileLayer"` - stores the tileIds of every single block in the level |
| 59 | + |
| 60 | +This uses RLE to store each |
| 61 | + |
| 62 | +`"rotation"` - stores rotation of the blocks in the level |
0 commit comments