Commit Graph

3 Commits (5bf7d554f7c4dcced458dc27fd2f02b360b4f739)

Author SHA1 Message Date
Noah 5bf7d554f7 Add doodad.exe binary and PNG to Drawing Converter
Adds the `doodad` binary which will be a command line tool to work with
Doodads and Levels and assist with development.

The `doodad` binary has subcommands like git and the first command is
`convert` which converts between image files (PNG or BMP) and Doodle
drawing files (Level or Doodad). You can "screenshot" a level into a PNG
or you can initialize a new drawing from a PNG.
2018-10-16 12:26:41 -07:00
Noah e25869644c Fix Play Mode, Level Handover & Collision Detection
* 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.
2018-09-25 09:40:34 -07:00
Noah 3c185528f9 Implement Chunk System for Pixel Data
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
2018-09-23 15:42:05 -07:00