Commit Graph

13 Commits (7f4640b727da2d92dcf5cab29e78bfe14f4d2f7d)

Author SHA1 Message Date
Noah 8126888b5b Drawing Strokes and Undo/Redo Functionality
* Add new pkg/drawtool with utilities to abstract away drawing actions
  into Strokes and track undo/redo History for them.
* The freehand Pencil tool in EditorMode has been refactored to create a
  Stroke of Shape=Freehand and queue up its world pixels there instead
  of directly modifying the level chunker in real time. When the mouse
  button is released, the freehand Stroke is committed to the level
  chunker and added to the UndoHistory.
* UndoHistory is (temporarily) stored with the level.Level so it can
  survive trips to PlayScene and back, but is not stored as JSON on
  disk.
* Ctrl-Z and Ctrl-Y in EditorMode for undo and redo, respectively.
2019-07-03 16:25:23 -07:00
Noah e682bb27c0 Demo Running Level as Title Screen Wallpaper
* Load SDL2 fonts from go-bindata storage so we don't have to ship
  external font files on disk.
* Dedupe names of doodads so we don't show double on the front-end
  (go-bindata bundled doodads + those on local filesystem)
* Use go-bindata for accessing wallpaper images.
* Better flashed messages walking you through the Link Tool.
* Stylize the title screen (MainScene) by rendering a live example level
  as the background wallpaper, with mobile doodads in motion.
2019-06-27 22:59:36 -07:00
Noah 981b2b98e0 Refactor Render Texture-Cache Interface
Since SDL2 is using in-memory bitmaps the same as Canvas engine, the
function names of the render.Engine interface have been cleaned up:

* NewTexture(filename, image) -> StoreTexture(name, image)
  Create a new cached texture with a given name.
* NewBitmap(filename) -> LoadTexture(name)
  Recall a stored texture with a given name.
* level.Chunk.ToBitmap uses simpler names for the textures instead of
  userdir.CacheFilename file-like paths.
2019-06-27 13:01:01 -07:00
Noah 4ad32c6edf SDL2: Cache Bitmaps in Memory, Not on Disk
* Update the SDL2 engine's texture caching to use an sdl.RWops file
  buffer in memory instead of outputting bitmap images to the
  filesystem.
2019-06-27 12:46:35 -07:00
Noah 5893daba58 WASM Texture Caching
* Refactor texture caching in render.Engine:
  * New interface method: NewTexture(filename string, image.Image)
  * WASM immediately encodes the image to PNG and generates a JavaScript
    `Image()` object to load it with a data URI and keep it in memory.
  * SDL2 saves the bitmap to disk as it did before.
  * WASM: deprecate the sessionStorage for holding image data. Session
    storage methods panic if called. The image data is directly kept in
    Go memory as a js.Value holding an Image().
* Shared Memory workaround: the level.Chunk.ToBitmap() function is where
  chunk textures get cached, but it had no access to the render.Engine
  used in the game. The `pkg/shmem` package holds global pointers to
  common structures like the CurrentRenderEngine as a work-around.
  * Also shmem.Flash() so Doodle can make its d.Flash() function
    globally available, any sub-package can now flash text to the screen
    regardless of source code location.
  * JavaScript API for Doodads now has a global Flash() function
    available.
* WASM: Handle window resize so Doodle can recompute its dimensions
  instead of scaling/shrinking the view.
2019-06-27 12:03:52 -07:00
Noah 03b4441eaa WASM Event Queue
* Refactor the event system in the WASM render engine to serialize the
  async JavaScript events into a channel, so that queued events are read
  off serially in the main loop similar to SDL. This fixes keyboard
  input issues, altho if you type really fast some input keys get lost.
2019-06-26 20:33:24 -07:00
Noah 5e9443bcff Add MenuScene with New Level UI
* Debug mode: no longer enables the DebugOverlay (F3) by default, but
  does now insert the current FPS counter into the window title bar.
* ui.Frame: set a default "mostly transparent" BG color so the frame
  background doesn't render as white.
* Add the MenuScene which will house the game's main menus.
* The "New Level" menu is first to be added.
  * UI lets you pick Page Type and Wallpaper using radio buttons.
  * Page Type: Unbounded, Bounded (default), No Negative Space, Bordered
  * Fix bugs in uix.Canvas to fully support all these page types.
2019-06-25 15:01:37 -07:00
Noah 7b264dffba Minor Tweaks 2019-06-08 17:02:28 -07:00
Noah 6c5542673a Remove ScreenshotKey Event, Add F* Key Handlers
* The F3 key now toggles the Debug Overlay, which is now OFF by default.
* The F4 key now toggles the Debug Collision Boxes feature.
2019-04-19 16:21:04 -07:00
Noah 95ef079724 Remove pkg/log from lib/render package
This breaks the last ties from the lib/ folder of publicly open
sourceable code from the internals of Doodle in pkg/
2019-04-18 22:14:02 -07:00
Noah 2ae77a8c82 Port over code from old collision dev PR 2019-04-09 19:17:56 -07:00
Noah 31e01987e5 Clean up extra log modules 2019-04-09 17:47:03 -07:00
Noah cddc41465f Code Layout Refactor
* All private Doodle source code into the pkg/ folder.
* Potentially public code into the lib/ folder.
* Centralize the logger into a subpackage.
2019-04-09 17:35:44 -07:00