* Edit Mode now uses the Level object itself to keep the drawing data
rather than pull its Palette and Chunks out, so it can hang on to more
information. The Canvas widget is given references to the
Level.Palette and Level.Chunker via Canvas.LoadLevel()
* Fix the handoff between Edit Mode and Play Mode. They pass the Level
object back and forth and the Filename, because it's not part of the
Level. You can save the map with its original settings after returning
from Play Mode.
* Fix the collision detection in Play Mode. It broke previously when
palettes were added because of the difference between a render.Point
and a level.Pixel and it couldn't easily look up coordinates. The new
Chunker system provides a render.Point lookup API.
* All pixels are solid for collision right now, TODO is to return Swatch
information from the pixels touching the player character and react
accordingly (non-solid, fire flag, etc.)
* Remove the level.Grid type as it has been replaced by the Chunker.
* Clean up some unused variables and functions.
Starts the implementation of the chunk-based pixel storage system for
levels and drawings.
Previously the levels had a Pixels structure which was just an array of
X,Y and palette index triplets. The new chunk system divides the map up
into square chunks, and lets each chunk manage its own memory layout.
The "MapAccessor" layout is implemented first which is a map of X,Y
coordinates to their Swatches (pointer to an index of the palette). When
serialized the MapAccessor maps the "X,Y": "index" similarly to the old
Pixels array.
The object hierarchy for the chunk system is like:
* Chunker: the manager of the chunks who keeps track of the ChunkSize
and a map of "chunk coordinates" to the chunk in charge of it.
* Chunk: a part of the drawing ChunkSize length square. A chunk has a
Type (of how it stores its data, 0 being a map[Point]Swatch and 1
being a [][]Swatch 2D array), and the chunk has an Accessor which
implements the underlying type.
* Accessor: an interface for a Chunk to provide access to its
pixels.
* MapAccessor: a "sparse map" of coordinates to their Swatches.
* GridAccessor: TBD, will be a "dense" 2D grid of Swatches.
The JSON files are loaded in two passes:
1. The chunks only load their swatch indexes from disk.
2. With the palette also loaded, the chunks are "inflated" and linked
to their swatch pointers.
Misc changes:
* The `level.Canvas` UI widget switches from the old Grid data type to
being able to directly use a `level.Chunker`
* The Chunker is a shared data type between the on-disk level format and
the actual renderer (level.Canvas), so saving the level is easy
because you can just pull the Chunker out from the canvas.
* ChunkSize is stored inside the level file and the default value is at
balance/numbers.go: 1000