doodle/pkg/shmem/globals.go
Noah Petherbridge 647124495b Level Difficulty + UI Polish
Added a new level property: Difficulty

* An enum ranging from -1, 0, 1 (Peaceful, Normal, Hard)
* Default difficulty is Normal; pre-existing levels are Normal by
  default per the zero value.

Doodad scripts can read the difficulty via the new global variable
`Level.Difficulty` and some doodads have been updated:

* Azulians: on Peaceful they ignore all player characters, and on Hard
  they are in "hunt mode": infinite aggro radius and they're aggressive
  to all characters.
* Bird: on Peaceful they will not dive and attack any player character.

Other spit and polish:

* New Level/Level Properties UI reworked into a magicform.
* New "PromptPre(question, answer, func)" function for prompting the
  user with the developer shell, but pre-filling in an answer for them
  to either post or edit.
* magicform has a PromptUser field option for simple Text/Int fields
  which present as buttons, so magicform can prompt and update the
  variable itself.
* Don't show the _autosave.doodad in the Doodad Dropper window.
2022-03-06 22:20:53 -08:00

46 lines
1.2 KiB
Go

package shmem
import (
"fmt"
"git.kirsle.net/go/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 position of the cursor relative to the window.
Cursor render.Point
// Current render engine (i.e. SDL2 or HTML5 Canvas)
// The level.Chunk.ToBitmap() uses this to cache a texture image.
CurrentRenderEngine render.Engine
// Offline mode, if True then the updates check in MainScene is skipped.
OfflineMode bool
// Globally available Flash() function so we can emit text to the Doodle UI.
Flash func(string, ...interface{})
FlashError func(string, ...interface{})
// Globally available Prompt() function.
Prompt func(string, func(string))
PromptPre func(string, string, func(string))
// 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...)
}
}