doodle/pkg/level
Noah 5654145fd8 (Experimental) Run Length Encoding for Levels
Finally add a second option for Chunk MapAccessor implementation besides the
MapAccessor. The RLEAccessor is basically a MapAccessor that will compress
your drawing with Run Length Encoding (RLE) in the on-disk format in the ZIP
file.

This slashes the file sizes of most levels:

* Shapeshifter: 21.8 MB -> 8.1 MB
* Jungle: 10.4 MB -> 4.1 MB
* Zoo: 2.8 MB -> 1.3 MB

Implementation details:

* The RLE binary format for Chunks is a stream of Uvarint pairs storing the
  palette index number and the number of pixels to repeat it (along the Y,X
  axis of the chunk).
    * Null colors are represented by a Uvarint that decodes to 0xFFFF
      or 65535 in decimal.
    * Gameplay logic currently limits maps to 256 colors.
* The default for newly created chunks in-game will be RLE by default.
* Its in-memory representation is still a MapAccessor (a map of absolute
  world coordinates to palette index).
* The game can still open and play legacy MapAccessor maps.
* On save in the editor, the game will upgrade/convert MapAccessor chunks over
  to RLEAccessors, improving on your level's file size with a simple re-save.

Current Bugs

* On every re-save to RLE, one pixel is lost in the bottom-right corner of
  each chunk. Each subsequent re-save loses one more pixel to the left, so what
  starts as a single pixel per chunk slowly evolves into a horizontal line.
* Some pixels smear vertically as well.
* Off-by-negative-one errors when some chunks Iter() their pixels but compute
  a relative coordinate of (-1,0)! Some mismatch between the stored world coords
  of a pixel inside the chunk vs. the chunk's assigned coordinate by the Chunker:
  certain combinations of chunk coord/abs coord.

To Do

* The `doodad touch` command should re-save existing levels to upgrade them.
2024-05-23 23:02:01 -07:00
..
giant_screenshot Resolve circular import errors for Doodle++ plugin 2024-04-18 22:12:56 -07:00
publishing Resolve circular import errors for Doodle++ plugin 2024-04-18 22:12:56 -07:00
rle (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
actor_options.go Slippery Pixels + Update Changelog for 0.13.1 2022-10-10 10:52:28 -07:00
actors.go Slippery Pixels + Update Changelog for 0.13.1 2022-10-10 10:52:28 -07:00
chunk.go (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
chunk_map.go (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
chunk_rle.go (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
chunk_test.go (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
chunker.go (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
chunker_migrate.go (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
chunker_test.go (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
chunker_zipfile.go (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
filesystem.go Level Screenshots and Thumbnails 2023-12-08 19:48:02 -08:00
fmt_json.go Unit test fixes and code cleanup 2023-12-02 12:33:14 -08:00
fmt_maintenance.go (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
fmt_readwrite.go (Experimental) Run Length Encoding for Levels 2024-05-23 23:02:01 -07:00
inflate.go Level Thumbnails on Story Mode Select 2023-12-09 14:59:31 -08:00
page_type.go Add MenuScene with New Level UI 2019-06-25 15:01:37 -07:00
palette.go Binary format for chunks in zipfiles 2023-02-18 12:45:36 -08:00
palette_defaults.go Update default level palettes for new pixel attributes 2022-10-10 11:17:11 -07:00
screenshot.go Level Screenshots and Thumbnails 2023-12-08 19:48:02 -08:00
swatch.go Slippery Pixels + Update Changelog for 0.13.1 2022-10-10 10:52:28 -07:00
types.go D++ Default Author and Embedded Doodads Error 2024-04-18 22:31:11 -07:00