doodle/pkg/shmem/globals.go
Noah Petherbridge a504658055 Centralized Tick Counter, Fix Actor Dragging Bug
* The game's tick counter was moved from Doodle.ticks to shmem.Tick
  where it is more easily available from every corner of the code.
* Fix a bug in the Level Editor where dragging an already-existing actor
  from one part of your map to another, would cause it to lose all its
  data (especially its UUID), breaking links to other doodads. Now the
  existing Actor catches a ride on the drag object to be reinserted
  later.
* Animate the Link Line visualizers between actors. They now animate a
  blinking color between magenta and grey-ish.
2019-07-05 16:04:36 -07:00

35 lines
848 B
Go

package shmem
import (
"fmt"
"git.kirsle.net/apps/doodle/lib/render"
)
// Shared globals for easy access throughout the app.
// Not an ideal place to keep things but *shrug*
var (
// Tick is incremented by the main game loop each frame.
Tick uint64
// Current render engine (i.e. SDL2 or HTML5 Canvas)
// The level.Chunk.ToBitmap() uses this to cache a texture image.
CurrentRenderEngine render.Engine
// Globally available Flash() function so we can emit text to the Doodle UI.
Flash func(string, ...interface{})
// Ajax file cache for WASM use.
AjaxCache map[string][]byte
)
func init() {
AjaxCache = map[string][]byte{}
// Default Flash function in case the app misconfigures it. Output to the
// console in an obvious way.
Flash = func(tmpl string, v ...interface{}) {
fmt.Printf("[shmem.Flash] "+tmpl+"\n", v...)
}
}