Documentation ¶
Index ¶
- Constants
- Variables
- func BoolEnv(name string, v bool) bool
- func BoolProp(name string, v bool) error
- func ColorEnv(name string, v render.Color) render.Color
- func FeaturesOn()
- func GetBoolProp(name string) (bool, error)
- func IntEnv(name string, v int) int
- func IsBreakpointTablet(width, height int) bool
- func IsPlayerCharacterDefault() bool
- func IsShortWide(width, height int) bool
- type Boolprop
- type Format
Constants ¶
const ( // Enable "v1.5" compression in the MapAccessor Chunker. // // The original MapAccessor encodes a chunk to json using syntax like // {"x,y": index} mapping coordinates to palette swatches. // // With compression on, it is encoded to a byte stream of x,y,index // triplets. The game can read both formats and will follow this flag // on all saves. NOTE: this applies to when we still use JSON format. // If BinaryChunkerEnabled, map accessors are always compressed as they // are written to .bin files instead of .json. CompressMapAccessor = true // Enable "v2" binary storage of Chunk data in Zipfiles. // // This is a separate toggle to the CompressMapAccessor. Some possible // variations of these flags includes: // // - CompressMapAccessor=true alone, will write the compressed bytes // still wrapped in the JSON format as a Base64 encoded string. // - With BinaryChunkerEnabled=true: all chunks are encoded to // binary and put in the zip as .bin instead of as .json files. // MapAccessor is always compressed in binary mode. // // If you set both flags to false, level zipfiles will use the classic // json chunk format as before on save. BinaryChunkerEnabled = true // Enable "v3" Run-Length Encoding for level chunker. // // This only supports Zipfile levels and will use the ".bin" format // enabled by the previous setting. RLEBinaryChunkerEnabled = true )
Hard-coded feature flags.
const ( // Main UI fonts (sans-serif and monospace) SansSerifFont = "DejaVuSans.ttf" MonospaceFont = "DejaVuSansMono.ttf" SansBoldFont = "DejaVuSans-Bold.ttf" )
Font filenames used as part of game configuration.
const ( TargetFPS = 60 TargetClockRate = 1000 / 60 // wallclock milliseconds per tick )
Target frame rate for the game (also ticks per second for logic).
const ( // Title screen height needed for the main menu. Phones in landscape // mode will switch to the horizontal layout if less than this height. TitleScreenResponsiveHeight = 600 BreakpointMobile = 0 // 0-768 BreakpointTablet = 769 // from 769 BreakpointDesktop = 1024 // from 1024 BreakpointWidescreen = 1216 BreakpointFullHD = 1408 )
Responsive breakpoints and dimensions for Sketchy Maze.
Ideas for breakpoints (copying web CSS frameworks):
- Mobile up to 768px
- Tablet from 769px
- Desktop from 1024px
- Widescreen from 1216px
- FullHD from 1408px
const ( Linux platform = "linux" Windows platform = "windows" Darwin platform = "darwin" Web platform = "web" )
Runtime.Platform constants.
const DPP = false
Doodle++ tag compiled in.
Variables ¶
var ( CheatUncapFPS = "unleash the beast" CheatEditDuringPlay = "don't edit and drive" CheatScrollDuringPlay = "scroll scroll scroll your boat" CheatAntigravity = "import antigravity" CheatNoclip = "ghost mode" CheatShowAllActors = "show all actors" CheatGiveKeys = "give all keys" CheatGiveGems = "give all gems" CheatDropItems = "drop all items" CheatPlayAsBird = "fly like a bird" CheatGodMode = "god mode" CheatDebugLoadScreen = "test load screen" CheatDebugWaitScreen = "test wait screen" CheatUnlockLevels = "master key" CheatSkipLevel = "warp whistle" CheatFreeEnergy = "tesla" )
The game's cheat codes
var ( // Debug overlay (FPS etc.) settings. DebugFontFilename = SansBoldFont DebugFontSize = 14 DebugLabelColor = render.MustHexColor("#FF9900") DebugValueColor = render.MustHexColor("#00CCFF") DebugStrokeDarken = 80 // Background color to use when exporting a drawing Chunk as a bitmap image // on disk. Default is white. Setting this to translucent yellow is a great // way to visualize the chunks loaded from cache on your screen. DebugChunkBitmapBackground = render.Invisible // XXX: export $DEBUG_CHUNK_COLOR // Put a border around all Canvas widgets. DebugCanvasBorder = render.Invisible DebugCanvasLabel = false // Tag the canvas with a label. // Set to a color other than Invisible to force the uix.Canvas to color ALL // Stroke pixels in this color. DebugCanvasStrokeColor = render.Invisible )
Debug related variables that can toggle on or off certain features and overlays within the game.
var ( // Window dimensions. Width = 1024 Height = 768 // Speed to scroll a canvas with arrow keys in Edit Mode. CanvasScrollSpeed = 8 FollowActorMaxScrollSpeed = 64 // Window scrolling behavior in Play Mode. ScrollboxOffset = render.Point{ X: 60, Y: 60, } // Threshold of how many ticks should pass between the last Fingers Up // event and a mouse movement, to indicate that TouchScreenMode should end. TouchScreenModeLastFingerDownTicks uint64 = 10 // Player speeds, gravity and movement physics. PlayerMaxVelocity float64 = 7 PlayerJumpVelocity float64 = -15 PlayerAcceleration float64 = 0.04 // 0.12 PlayerFriction float64 = 0.1 SlipperyAcceleration float64 = 0.02 SlipperyFriction float64 = 0.02 GravityMaximum float64 = 7 // max pull of gravity GravityAcceleration float64 = 0.25 // normal gravity acceleration downward GravityJumpAcceleration float64 = 0.05 // gravity while jumping upward (smoother jumps) SwimGravity float64 = 3 SwimJumpVelocity float64 = -12 SwimJumpCooldown uint64 = 24 // number of frames of cooldown between swim-jumps CoyoteFrames uint64 = 4 // Coyote time, frames after we walk off a cliff but can still jump late SlopeMaxHeight = 8 // max pixel height for player to walk up a slope // Number of game ticks to insist the canvas follows the player at the start // of a level - to overcome Anvils settling into their starting positions so // they don't steal the camera focus straight away. FollowPlayerFirstTicks uint64 = 20 // Default chunk size for canvases. ChunkSize uint8 = 128 // Default size for a new Doodad. DoodadSize = 100 // Size of Undo/Redo history for map editor. UndoHistory = 20 // Options for brush size. BrushSizeOptions = []int{ 0, 1, 2, 4, 8, 16, 24, 32, 48, 64, } DefaultEraserBrushSize = 8 MaxEraserBrushSize = 32 // the bigger, the slower // Default font filename selected for Text Tool in the editor. // TODO: better centralize font filenames, here and in theme.go TextToolDefaultFont = SansSerifFont // Interval for auto-save in the editor AutoSaveInterval = 5 * time.Minute // Default player character doodad in Play Mode. PlayerCharacterDoodad = "boy.doodad" // Levelpack and level names for the title screen. DemoLevelPack = "assets/levelpacks/builtin-Tutorial.levelpack" DemoLevelName = []string{ "Tutorial 1.level", "Tutorial 2.level", "Tutorial 3.level", "Tutorial 5.level", } // Level attachment filename for the custom wallpaper. // NOTE: due to hard-coded "assets/wallpapers/" prefix in uix/canvas.go#LoadLevel. CustomWallpaperFilename = "custom.b64img" CustomWallpaperEmbedPath = "assets/wallpapers/custom.b64img" // Publishing: Doodads-embedded-within-levels. EmbeddedDoodadsBasePath = "assets/doodads/" EmbeddedWallpaperBasePath = "assets/wallpapers/" // File formats: save new levels and doodads gzip compressed DrawingFormat = FormatZipfile // Zipfile drawings: max size of the LRU cache for loading chunks from // a zip file. Normally the chunker discards chunks not loaded in a // recent tick, but when iterating the full level this limits the max // size of loaded chunks before some will be freed to make room. // 0 = do not cap the cache. ChunkerLRUCacheMax = 0 // Play Mode Touchscreen controls. PlayModeIdleTimeout = 2200 * time.Millisecond PlayModeAlphaStep = 8 // 0-255 alpha, steps per tick for fade in PlayModeAlphaMax = 220 // Invulnerability time in seconds at respawn from checkpoint, in case // enemies are spawn camping. RespawnGodModeTimer = 3 * time.Second // GameController thresholds. GameControllerMouseMoveMax float64 = 20 // Max pixels per tick to simulate mouse movement. GameControllerScrollMin float64 = 0.3 // Minimum threshold for a right-stick scroll event. // Limits on the Flood Fill tool so it doesn't run away on us. FloodToolVoidLimit = 600 // If clicking the void, +- 1000 px limit FloodToolLimit = 1200 // If clicking a valid color on the level // Eager render level chunks to images during the load screen. // Originally chunks rendered to image and SDL texture on-demand, the loadscreen was // added to eager load (to image) the whole entire level at once (SDL textures were // still on demand, as they scroll into screen). Control this in-game with // `boolProp eager-render false` and the loadscreen will go quicker cuz it won't // load the whole entire level. Maybe useful to explore memory issues. EagerRenderLevelChunks = true // Number of chunks margin outside the Canvas Viewport for the LoadingViewport. LoadingViewportMarginChunks = render.NewPoint(10, 8) // hoz, vert CanvasLoadUnloadModuloTicks uint64 = 4 CanvasChunkFreeChoppingBlockTicks uint64 = 128 // number of ticks old a chunk is to free it // For bounded levels, the game will try and keep actors inside the boundaries. But // in case e.g. the player is teleported far out of the boundaries (going thru a warp // door into an interior room "off the map"), allow them to be out of bounds. This // variable is the tolerance offset - if they are only this far out of bounds, put them // back in bounds but further out and they're OK. OutOfBoundsMargin = 40 // Level screenshot dimensions saved within the level data. LevelScreenshotLargeFilename = "large.png" LevelScreenshotMediumFilename = "medium.png" LevelScreenshotSmallFilename = "small.png" LevelScreenshotTinyFilename = "tiny.png" LevelScreenshotLargeSize = render.NewRect(1280, 720) LevelScreenshotMediumSize = render.NewRect(640, 360) LevelScreenshotSmallSize = render.NewRect(320, 180) // Level Properties thumbnail size LevelScreenshotTinySize = render.NewRect(224, 126) // Story Mode thumbnail size )
Numbers.
var ( // Number of Doodads per row in the palette. UIDoodadsPerRow = 2 // Size of the DoodadButtons on actor canvas mouseover. UICanvasDoodadButtonSize = 16 // Threshold for "very small doodad" where the buttons take up too big a proportion // and the doodad can't drag/drop easily.. tiny doodads will show the DoodadButtons // 50% off the top/right edge. UICanvasDoodadButtonSpaceNeeded = 20 )
Edit Mode Values
var ( Runtime rtc GuidebookPath = "./guidebook/index.html" )
Runtime environment settings.
var ( ShellFontFilename = MonospaceFont ShellBackgroundColor = render.RGBA(0, 20, 40, 200) ShellForegroundColor = render.RGBA(0, 153, 255, 255) ShellPromptColor = render.White ShellPadding = 8 ShellFontSize = 16 ShellFontSizeSmall = 10 ShellCursorBlinkRate uint64 = 20 ShellHistoryLineCount = 8 // Ticks that a flashed message persists for. FlashTTL uint64 = 400 )
Shell related variables.
var ( // Sprite filenames. WindowIcon = "assets/icons/96.png" GoldCoin = "assets/sprites/gold.png" SilverCoin = "assets/sprites/silver.png" LockIcon = "assets/sprites/padlock.png" GearIcon = "assets/sprites/gear.png" // Cursors CursorIcon = "assets/sprites/pointer.png" PencilIcon = "assets/sprites/pencil.png" FloodCursor = "assets/sprites/flood-cursor.png" // Pixel attributes AttrSolid = "assets/sprites/attr-solid.png" AttrFire = "assets/sprites/attr-fire.png" AttrWater = "assets/sprites/attr-water.png" AttrSemiSolid = "assets/sprites/attr-semisolid.png" AttrSlippery = "assets/sprites/attr-slippery.png" // Title Screen Font TitleScreenFont = render.Text{ Size: 46, Color: render.Pink, Stroke: render.SkyBlue, Shadow: render.Black, } TitleScreenSubtitleFont = render.Text{ FontFilename: SansSerifFont, Size: 18, Color: render.SkyBlue, Shadow: render.SkyBlue.Darken(128), } TitleScreenVersionFont = render.Text{ Size: 14, Color: render.Grey, Shadow: render.Black, } // Loading Screen fonts. LoadScreenFont = render.Text{ Size: 46, Color: render.Pink, Stroke: render.SkyBlue, Shadow: render.Black, } LoadScreenSecondaryFont = render.Text{ FontFilename: SansSerifFont, Size: 18, Color: render.SkyBlue, Shadow: render.SkyBlue.Darken(128), } // Play Mode Touch UI Hints Font TouchHintsFont = render.Text{ FontFilename: SansSerifFont, Size: 14, Color: render.SkyBlue, Shadow: render.SkyBlue.Darken(128), Padding: 8, PadY: 12, } // Window and panel styles. TitleConfig = ui.Config{ Background: render.MustHexColor("#FF9900"), OutlineSize: 1, OutlineColor: render.Black, } TitleFont = render.Text{ FontFilename: SansBoldFont, Size: 9, Padding: 4, Color: render.White, Stroke: render.Red, } WindowBackground = render.MustHexColor("#cdb689") WindowBorder = render.Grey // Developer Shell and Flashed Messages styles. FlashStrokeDarken = 60 FlashShadowDarken = 120 FlashFont = func(text string) render.Text { return render.Text{ Text: text, Size: 18, Color: render.SkyBlue, Stroke: render.SkyBlue.Darken(FlashStrokeDarken), Shadow: render.SkyBlue.Darken(FlashShadowDarken), } } FlashErrorColor = render.MustHexColor("#FF9900") // Menu bar styles. MenuBackground = render.Black MenuFont = render.Text{ Size: 12, PadX: 4, PadY: 2, } MenuFontBold = render.Text{ FontFilename: SansBoldFont, Size: 12, PadX: 4, } // TabFrame styles. TabFont = render.Text{ Size: 12, PadX: 8, PadY: 4, } // Pager styles. PagerLargeFont = render.Text{ FontFilename: SansBoldFont, Size: 14, PadX: 6, PadY: 4, } // Modal backdrop color. ModalBackdrop = render.RGBA(1, 1, 1, 42) // StatusFont is the font for the status bar. StatusFont = render.Text{ Size: 12, Padding: 4, Color: render.Black, } // UIFont is the main font for UI labels. UIFont = render.Text{ Size: 12, Padding: 4, Color: render.Black, } // DangerFont is a red version of UIFont. DangerFont = render.Text{ Size: 12, Padding: 4, Color: render.Red, } // LabelFont is the font for strong labels in UI. LabelFont = render.Text{ Size: 12, FontFilename: SansBoldFont, Padding: 4, Color: render.Black, } // A New Record! Label (Gold/Perfect and Silver/Normal) NewRecordPerfectFont = LabelFont.Update(render.Text{ Color: render.Yellow, Stroke: render.Orange, }) NewRecordFont = LabelFont.Update(render.Text{ Color: render.White, Stroke: render.Grey, }) LargeLabelFont = render.Text{ Size: 18, FontFilename: SansBoldFont, Padding: 4, Color: render.Black, } // SmallMonoFont for cramped spaces like the +/- buttons on Toolbar. SmallMonoFont = render.Text{ Size: 14, PadX: 3, FontFilename: MonospaceFont, Color: render.Black, } // CodeLiteralFont for rendering <code>-like text. CodeLiteralFont = render.Text{ Size: 11, PadX: 3, FontFilename: MonospaceFont, Color: render.Magenta, } // ExceptionFont for showing JavaScript errors to the user. ExceptionFont = render.Text{ Size: 12, PadX: 3, FontFilename: MonospaceFont, Color: render.Black, } // Small font SmallFont = render.Text{ Size: 10, Padding: 2, Color: render.Black, } // Color for draggable doodad. DragColor = render.MustHexColor("#0099FF") // Link lines drawn between connected doodads. LinkLineColor = render.Magenta LinkLighten = 128 LinkAnimSpeed uint64 = 30 // ticks PlayButtonFont = render.Text{ FontFilename: SansBoldFont, Size: 16, Padding: 4, Color: render.RGBA(255, 255, 0, 255), Stroke: render.RGBA(100, 100, 0, 255), } // In-game level timer font. TimerFont = render.Text{ FontFilename: MonospaceFont, Size: 16, Color: render.Cyan, Stroke: render.DarkCyan, } // Doodad Dropper Window settings. DoodadButtonBackground = render.RGBA(255, 255, 200, 255) DoodadButtonSize = 64 DoodadDropperCols = 6 // rows/columns of buttons DoodadDropperRows = 3 // CheatsMenu window settings. CheatsMenuBackground = render.RGBA(0, 153, 153, 255) // Button styles, customized in init(). ButtonPrimary = style.DefaultButton ButtonDanger = style.DefaultButton ButtonBabyBlue = style.DefaultButton ButtonPink = style.DefaultButton ButtonLightRed = style.DefaultButton DefaultCrosshairColor = render.RGBA(0, 153, 255, 255) // Default built-in wallpapers. Wallpapers = []magicform.Option{ { Label: "Notebook", Value: "notebook.png", }, { Label: "Legal Pad", Value: "legal.png", }, { Label: "Graph paper", Value: "graph.png", }, { Label: "Dotted paper", Value: "dots.png", }, { Label: "Dotted paper (dark)", Value: "dots-dark.png", }, { Label: "Blueprint", Value: "blueprint.png", }, { Label: "Red parchment", Value: "red-parchment.png", }, { Label: "Green parchment", Value: "green-parchment.png", }, { Label: "Blue parchment", Value: "blue-parchment.png", }, { Label: "Yellow parchment", Value: "yellow-parchment.png", }, { Label: "White parchment", Value: "white-parchment.png", }, { Label: "Pure white", Value: "white.png", }, { Label: "Atmosphere", Value: "atmosphere.png", }, { Separator: true, }, { Label: "Custom wallpaper...", Value: CustomWallpaperFilename, }, } )
Theme and appearance variables.
var Boolprops = map[string]Boolprop{ "show-hidden-doodads": { Get: func() bool { return usercfg.Current.ShowHiddenDoodads }, Set: func(v bool) { usercfg.Current.ShowHiddenDoodads = v }, }, "write-lock-override": { Get: func() bool { return usercfg.Current.WriteLockOverride }, Set: func(v bool) { usercfg.Current.WriteLockOverride = v }, }, "pretty-json": { Get: func() bool { return usercfg.Current.JSONIndent }, Set: func(v bool) { usercfg.Current.JSONIndent = v }, }, "horizontal-toolbars": { Get: func() bool { return usercfg.Current.HorizontalToolbars }, Set: func(v bool) { usercfg.Current.HorizontalToolbars = v }, }, "eager-render": { Get: func() bool { return EagerRenderLevelChunks }, Set: func(v bool) { EagerRenderLevelChunks = v }, }, }
Boolprops are the map of available boolprops, shown in the dev console when you type: "boolProp list"
var CheatActors = map[string]string{ "pinocchio": PlayerCharacterDoodad, "the cell": "azu-blu", "super azulian": "azu-red", "hyper azulian": "azu-white", "fly like a bird": "bird-red", "bluebird": "bird-blue", "megaton weight": "anvil", "play as thief": "thief", }
Actor replacement cheats
var (
CheatEnabledUnlockLevels bool
)
Global cheat boolean states.
var CheatMenuActors = []magicform.Option{
{
Value: "",
Label: "Play as . . .",
},
{
Value: "boy.doodad",
Label: "Boy",
},
{
Value: "thief.doodad",
Label: "Thief",
},
{
Value: "azu-blu.doodad",
Label: "Azulian",
},
{
Value: "bird-red.doodad",
Label: "Bird",
},
{
Value: "crusher.doodad",
Label: "Crusher",
},
{
Value: "snake.doodad",
Label: "Snake",
},
{
Value: "anvil.doodad",
Label: "Anvil",
},
}
Options for the "Play as:" drop-down in the Cheat Menu window.
var ( // Disable chunk texture caching (SLOW!) DisableChunkTextureCache = false )
var Feature = feature{ ViewportWindow: false, CustomWallpaper: true, EmbeddableDoodads: true, Zoom: true, ChangePalette: true, LoadUnloadChunk: true, }
Feature Flags to turn on/off experimental content.
Functions ¶
func ColorEnv ¶
ColorEnv gets a color value from environment variable or returns a default. This will panic if the color is not valid, so only do this on startup time.
func FeaturesOn ¶
func FeaturesOn()
FeaturesOn turns on all feature flags, from CLI --experimental option.
func GetBoolProp ¶
GetBoolProp reads the current value of a boolProp. Special value "list" will error out with a list of available props.
func IsBreakpointTablet ¶
func IsPlayerCharacterDefault ¶
func IsPlayerCharacterDefault() bool
IsPlayerCharacterDefault returns whether the balance.PlayerCharacterDoodad has been modified at runtime away from its built-in default. This is a cheat detection method: high scores could be tainted if you `fly like a bird` right to the exit in a couple of seconds.
func IsShortWide ¶
IsShortWide is a custom responsive breakpoint to mimic the mobile app in landscape mode like on a Pinephone.
Parameters are the width and height of the application window (usually the screen if maximized).
It is used on the MainScene to decide whether the main menu is drawn tall or wide.
Types ¶
type Boolprop ¶
Boolprop is a boolean setting that can be toggled in the game using the developer console. Many of these consist of usercfg settings that are not exposed to the Settings UI window, and secret testing functions. Where one points to usercfg, check usercfg.Settings for documentation about what that boolean does.