2018-08-17 03:37:19 +00:00
|
|
|
package balance
|
|
|
|
|
2021-10-05 02:51:31 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"git.kirsle.net/go/render"
|
|
|
|
)
|
2021-06-14 03:25:42 +00:00
|
|
|
|
2022-04-30 03:34:59 +00:00
|
|
|
// Format for level and doodad files.
|
|
|
|
type Format int
|
|
|
|
|
|
|
|
const (
|
|
|
|
FormatJSON Format = iota // v0: plain json files
|
|
|
|
FormatGZip // v1: gzip compressed json files
|
|
|
|
FormatZipfile // v2: zip archive with external chunks
|
|
|
|
)
|
|
|
|
|
2024-04-27 07:10:28 +00:00
|
|
|
// Target frame rate for the game (also ticks per second for logic).
|
|
|
|
const (
|
|
|
|
TargetFPS = 60
|
|
|
|
TargetClockRate = 1000 / 60 // wallclock milliseconds per tick
|
|
|
|
)
|
|
|
|
|
2018-08-17 03:37:19 +00:00
|
|
|
// Numbers.
|
|
|
|
var (
|
2018-10-08 17:38:49 +00:00
|
|
|
// Window dimensions.
|
|
|
|
Width = 1024
|
|
|
|
Height = 768
|
|
|
|
|
2018-08-17 03:37:19 +00:00
|
|
|
// Speed to scroll a canvas with arrow keys in Edit Mode.
|
2021-08-16 03:17:53 +00:00
|
|
|
CanvasScrollSpeed = 8
|
|
|
|
FollowActorMaxScrollSpeed = 64
|
2018-09-23 22:20:45 +00:00
|
|
|
|
2019-04-10 01:28:08 +00:00
|
|
|
// Window scrolling behavior in Play Mode.
|
2021-06-14 03:25:42 +00:00
|
|
|
ScrollboxOffset = render.Point{ // from center of screen
|
2021-08-12 03:40:31 +00:00
|
|
|
X: 60,
|
2021-10-05 02:51:31 +00:00
|
|
|
Y: 60,
|
2021-06-14 03:25:42 +00:00
|
|
|
}
|
2019-04-10 01:28:08 +00:00
|
|
|
|
2024-04-20 06:13:32 +00:00
|
|
|
// 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
|
|
|
|
|
2024-02-07 04:56:07 +00:00
|
|
|
// Player speeds, gravity and movement physics.
|
2024-02-07 03:04:47 +00:00
|
|
|
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
|
2024-02-07 04:56:07 +00:00
|
|
|
CoyoteFrames uint64 = 4 // Coyote time, frames after we walk off a cliff but can still jump late
|
2024-02-07 03:04:47 +00:00
|
|
|
SlopeMaxHeight = 8 // max pixel height for player to walk up a slope
|
2019-04-10 01:28:08 +00:00
|
|
|
|
2022-09-25 06:54:51 +00:00
|
|
|
// 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.
|
Update savegame format, Allow out-of-bounds camera
Updates the savegame.json file format:
* Levels now have a UUID value assigned at first save.
* The savegame.json will now track level completion/score based on UUID,
making it robust to filename changes in either levels or levelpacks.
* The savegame file is auto-migrated on startup - for any levels not
found or have no UUID, no change is made, it's backwards compatible.
* Level Properties window adds an "Advanced" tab to show/re-roll UUID.
New JavaScript API for doodad scripts:
* `Actors.CameraFollowPlayer()` tells the camera to return focus to the
player character. Useful for "cutscene" doodads that freeze the player,
call `Self.CameraFollowMe()` and do a thing before unfreezing and sending the
camera back to the player. (Or it will follow them at their next directional
input control).
* `Self.MoveBy(Point(x, y int))` to move the current actor a bit.
New option for the `doodad` command-line tool:
* `doodad resave <.level or .doodad>` will load and re-save a drawing, to
migrate it to the newest file format versions.
Small tweaks:
* On bounded levels, allow the camera to still follow the player if the player
finds themselves WELL far out of bounds (40 pixels margin). So on bounded
levels you can create "interior rooms" out-of-bounds to Warp Door into.
* New wallpaper: "Atmosphere" has a black starscape pattern that fades into a
solid blue atmosphere.
* Camera strictly follows the player the first 20 ticks, not 60 of level start
* If player is frozen, directional inputs do not take the camera focus back.
2023-03-08 05:55:10 +00:00
|
|
|
FollowPlayerFirstTicks uint64 = 20
|
2022-09-25 06:54:51 +00:00
|
|
|
|
2018-09-23 22:20:45 +00:00
|
|
|
// Default chunk size for canvases.
|
2023-02-17 05:47:18 +00:00
|
|
|
ChunkSize uint8 = 128
|
2018-09-26 17:04:46 +00:00
|
|
|
|
|
|
|
// Default size for a new Doodad.
|
|
|
|
DoodadSize = 100
|
2019-07-03 23:22:30 +00:00
|
|
|
|
|
|
|
// Size of Undo/Redo history for map editor.
|
|
|
|
UndoHistory = 20
|
Eraser Tool, Brush Sizes
* Implement Brush Sizes for drawtool.Stroke and add a UI to the tools panel
to control the brush size.
* Brush sizes: 1, 2, 4, 8, 16, 24, 32, 48, 64
* Add the Eraser Tool to editor mode. It uses a default brush size of 16
and a max size of 32 due to some performance issues.
* The Undo/Redo system now remembers the original color of pixels when
you change them, so that Undo will set them back how they were instead
of deleting the pixel entirely. Due to performance issues, this only
happens when your Brush Size is 0 (drawing single-pixel shapes).
* UI: Add an IntVariable option to ui.Label to bind showing the value of
an int reference.
Aforementioned performance issues:
* When we try to remember whole rects of pixels for drawing thick
shapes, it requires a ton of scanning for each step of the shape. Even
de-duplicating pixel checks, tons of extra reads are constantly
checked.
* The Eraser is the only tool that absolutely needs to be able to
remember wiped pixels AND have large brush sizes. The performance
sucks and lags a bit if you erase a lot all at once, but it's a
trade-off for now.
* So pixels aren't remembered when drawing lines in your level with
thick brushes, so the Undo action will simply delete your pixels and not
reset them. Only the Eraser can bring back pixels.
2019-07-12 02:07:46 +00:00
|
|
|
|
|
|
|
// Options for brush size.
|
|
|
|
BrushSizeOptions = []int{
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
4,
|
|
|
|
8,
|
|
|
|
16,
|
|
|
|
24,
|
|
|
|
32,
|
|
|
|
48,
|
|
|
|
64,
|
|
|
|
}
|
|
|
|
DefaultEraserBrushSize = 8
|
|
|
|
MaxEraserBrushSize = 32 // the bigger, the slower
|
2020-09-19 05:35:43 +00:00
|
|
|
|
2022-03-05 23:31:09 +00:00
|
|
|
// Default font filename selected for Text Tool in the editor.
|
|
|
|
// TODO: better centralize font filenames, here and in theme.go
|
2022-03-06 06:44:54 +00:00
|
|
|
TextToolDefaultFont = SansSerifFont
|
2022-03-05 23:31:09 +00:00
|
|
|
|
2022-01-03 06:36:32 +00:00
|
|
|
// Interval for auto-save in the editor
|
|
|
|
AutoSaveInterval = 5 * time.Minute
|
|
|
|
|
2020-09-19 05:35:43 +00:00
|
|
|
// Default player character doodad in Play Mode.
|
2024-05-29 05:36:53 +00:00
|
|
|
PlayerCharacterDoodad = "example-mario.doodad"
|
2020-09-19 05:35:43 +00:00
|
|
|
|
2022-02-21 01:46:16 +00:00
|
|
|
// Levelpack and level names for the title screen.
|
Update savegame format, Allow out-of-bounds camera
Updates the savegame.json file format:
* Levels now have a UUID value assigned at first save.
* The savegame.json will now track level completion/score based on UUID,
making it robust to filename changes in either levels or levelpacks.
* The savegame file is auto-migrated on startup - for any levels not
found or have no UUID, no change is made, it's backwards compatible.
* Level Properties window adds an "Advanced" tab to show/re-roll UUID.
New JavaScript API for doodad scripts:
* `Actors.CameraFollowPlayer()` tells the camera to return focus to the
player character. Useful for "cutscene" doodads that freeze the player,
call `Self.CameraFollowMe()` and do a thing before unfreezing and sending the
camera back to the player. (Or it will follow them at their next directional
input control).
* `Self.MoveBy(Point(x, y int))` to move the current actor a bit.
New option for the `doodad` command-line tool:
* `doodad resave <.level or .doodad>` will load and re-save a drawing, to
migrate it to the newest file format versions.
Small tweaks:
* On bounded levels, allow the camera to still follow the player if the player
finds themselves WELL far out of bounds (40 pixels margin). So on bounded
levels you can create "interior rooms" out-of-bounds to Warp Door into.
* New wallpaper: "Atmosphere" has a black starscape pattern that fades into a
solid blue atmosphere.
* Camera strictly follows the player the first 20 ticks, not 60 of level start
* If player is frozen, directional inputs do not take the camera focus back.
2023-03-08 05:55:10 +00:00
|
|
|
DemoLevelPack = "assets/levelpacks/builtin-Tutorial.levelpack"
|
2022-01-03 06:36:32 +00:00
|
|
|
DemoLevelName = []string{
|
|
|
|
"Tutorial 1.level",
|
|
|
|
"Tutorial 2.level",
|
|
|
|
"Tutorial 3.level",
|
Update savegame format, Allow out-of-bounds camera
Updates the savegame.json file format:
* Levels now have a UUID value assigned at first save.
* The savegame.json will now track level completion/score based on UUID,
making it robust to filename changes in either levels or levelpacks.
* The savegame file is auto-migrated on startup - for any levels not
found or have no UUID, no change is made, it's backwards compatible.
* Level Properties window adds an "Advanced" tab to show/re-roll UUID.
New JavaScript API for doodad scripts:
* `Actors.CameraFollowPlayer()` tells the camera to return focus to the
player character. Useful for "cutscene" doodads that freeze the player,
call `Self.CameraFollowMe()` and do a thing before unfreezing and sending the
camera back to the player. (Or it will follow them at their next directional
input control).
* `Self.MoveBy(Point(x, y int))` to move the current actor a bit.
New option for the `doodad` command-line tool:
* `doodad resave <.level or .doodad>` will load and re-save a drawing, to
migrate it to the newest file format versions.
Small tweaks:
* On bounded levels, allow the camera to still follow the player if the player
finds themselves WELL far out of bounds (40 pixels margin). So on bounded
levels you can create "interior rooms" out-of-bounds to Warp Door into.
* New wallpaper: "Atmosphere" has a black starscape pattern that fades into a
solid blue atmosphere.
* Camera strictly follows the player the first 20 ticks, not 60 of level start
* If player is frozen, directional inputs do not take the camera focus back.
2023-03-08 05:55:10 +00:00
|
|
|
"Tutorial 5.level",
|
2022-01-03 06:36:32 +00:00
|
|
|
}
|
2021-06-07 01:59:04 +00:00
|
|
|
|
|
|
|
// Level attachment filename for the custom wallpaper.
|
|
|
|
// NOTE: due to hard-coded "assets/wallpapers/" prefix in uix/canvas.go#LoadLevel.
|
2021-06-13 21:53:21 +00:00
|
|
|
CustomWallpaperFilename = "custom.b64img"
|
2021-06-07 01:59:04 +00:00
|
|
|
CustomWallpaperEmbedPath = "assets/wallpapers/custom.b64img"
|
2021-06-13 21:53:21 +00:00
|
|
|
|
|
|
|
// Publishing: Doodads-embedded-within-levels.
|
|
|
|
EmbeddedDoodadsBasePath = "assets/doodads/"
|
|
|
|
EmbeddedWallpaperBasePath = "assets/wallpapers/"
|
2021-07-14 02:23:09 +00:00
|
|
|
|
|
|
|
// File formats: save new levels and doodads gzip compressed
|
2022-04-30 03:34:59 +00:00
|
|
|
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
|
2021-10-05 02:51:31 +00:00
|
|
|
|
|
|
|
// Play Mode Touchscreen controls.
|
|
|
|
PlayModeIdleTimeout = 2200 * time.Millisecond
|
|
|
|
PlayModeAlphaStep = 8 // 0-255 alpha, steps per tick for fade in
|
|
|
|
PlayModeAlphaMax = 220
|
2022-01-19 02:32:15 +00:00
|
|
|
|
|
|
|
// Invulnerability time in seconds at respawn from checkpoint, in case
|
|
|
|
// enemies are spawn camping.
|
|
|
|
RespawnGodModeTimer = 3 * time.Second
|
2022-02-20 02:25:36 +00:00
|
|
|
|
|
|
|
// 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.
|
2022-03-26 20:55:06 +00:00
|
|
|
|
|
|
|
// 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
|
2022-04-10 01:21:26 +00:00
|
|
|
|
|
|
|
// 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
|
2022-04-10 19:39:27 +00:00
|
|
|
|
|
|
|
// Number of chunks margin outside the Canvas Viewport for the LoadingViewport.
|
2022-05-08 00:16:03 +00:00
|
|
|
LoadingViewportMarginChunks = render.NewPoint(10, 8) // hoz, vert
|
|
|
|
CanvasLoadUnloadModuloTicks uint64 = 4
|
|
|
|
CanvasChunkFreeChoppingBlockTicks uint64 = 128 // number of ticks old a chunk is to free it
|
Update savegame format, Allow out-of-bounds camera
Updates the savegame.json file format:
* Levels now have a UUID value assigned at first save.
* The savegame.json will now track level completion/score based on UUID,
making it robust to filename changes in either levels or levelpacks.
* The savegame file is auto-migrated on startup - for any levels not
found or have no UUID, no change is made, it's backwards compatible.
* Level Properties window adds an "Advanced" tab to show/re-roll UUID.
New JavaScript API for doodad scripts:
* `Actors.CameraFollowPlayer()` tells the camera to return focus to the
player character. Useful for "cutscene" doodads that freeze the player,
call `Self.CameraFollowMe()` and do a thing before unfreezing and sending the
camera back to the player. (Or it will follow them at their next directional
input control).
* `Self.MoveBy(Point(x, y int))` to move the current actor a bit.
New option for the `doodad` command-line tool:
* `doodad resave <.level or .doodad>` will load and re-save a drawing, to
migrate it to the newest file format versions.
Small tweaks:
* On bounded levels, allow the camera to still follow the player if the player
finds themselves WELL far out of bounds (40 pixels margin). So on bounded
levels you can create "interior rooms" out-of-bounds to Warp Door into.
* New wallpaper: "Atmosphere" has a black starscape pattern that fades into a
solid blue atmosphere.
* Camera strictly follows the player the first 20 ticks, not 60 of level start
* If player is frozen, directional inputs do not take the camera focus back.
2023-03-08 05:55:10 +00:00
|
|
|
|
|
|
|
// 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
|
2023-12-09 03:48:02 +00:00
|
|
|
|
|
|
|
// Level screenshot dimensions saved within the level data.
|
|
|
|
LevelScreenshotLargeFilename = "large.png"
|
|
|
|
LevelScreenshotMediumFilename = "medium.png"
|
|
|
|
LevelScreenshotSmallFilename = "small.png"
|
2023-12-09 22:59:31 +00:00
|
|
|
LevelScreenshotTinyFilename = "tiny.png"
|
2023-12-09 03:48:02 +00:00
|
|
|
LevelScreenshotLargeSize = render.NewRect(1280, 720)
|
|
|
|
LevelScreenshotMediumSize = render.NewRect(640, 360)
|
2023-12-09 22:59:31 +00:00
|
|
|
LevelScreenshotSmallSize = render.NewRect(320, 180) // Level Properties thumbnail size
|
|
|
|
LevelScreenshotTinySize = render.NewRect(224, 126) // Story Mode thumbnail size
|
2018-08-17 03:37:19 +00:00
|
|
|
)
|
2018-10-20 22:42:49 +00:00
|
|
|
|
|
|
|
// Edit Mode Values
|
|
|
|
var (
|
|
|
|
// Number of Doodads per row in the palette.
|
|
|
|
UIDoodadsPerRow = 2
|
Doodad/Actor Runtime Options
* Add "Options" support for Doodads: these allow for individual Actor instances
on your level to customize properties about the doodad. They're like "Tags"
except the player can customize them on a per-actor basis.
* Doodad Editor: you can specify the Options in the Doodad Properties window.
* Level Editor: when the Actor Tool is selected, on mouse-over of an actor,
clicking on the gear icon will open a new "Actor Properties" window which
shows metadata (title, author, ID, position) and an Options tab to configure
the actor's options.
Updates to the scripting API:
* Self.Options() returns a list of option names defined on the Doodad.
* Self.GetOption(name) returns the value for the named option, or nil if
neither the actor nor its doodad have the option defined. The return type
will be correctly a string, boolean or integer type.
Updates to the doodad command-line tool:
* `doodad show` will print the Options on a .doodad file and, when showing a
.level file with --actors, prints any customized Options with the actors.
* `doodad edit-doodad` adds a --option parameter to define options.
Options added to the game's built-in doodads:
* Warp Doors: "locked (exit only)" will make it so the door can not be opened
by the player, giving the "locked" message (as if it had no linked door),
but the player may still exit from the door if sent by another warp door.
* Electric Door & Electric Trapdoor: "opened" can make the door be opened by
default when the level begins instead of closed. A switch or a button that
removes power will close the door as normal.
* Colored Doors & Small Key Door: "unlocked" will make the door unlocked at
level start, not requiring a key to open it.
* Colored Keys & Small Key: "has gravity" will make the key subject to gravity
and set its Mobile flag so that if it falls onto a button, it will activate.
* Gemstones: they had gravity by default; you can now uncheck "has gravity" to
remove their Gravity and IsMobile status.
* Gemstone Totems: "has gemstone" will set the totem to its unlocked status by
default with the gemstone inserted. No power signal will be emitted; it is
cosmetic only.
* Fire Region: "name" can let you set a name for the fire region similarly to
names for fire pixels: "Watch out for ${name}!"
* Invisible Warp Door: "locked (exit only)" added as well.
2022-10-10 00:41:24 +00:00
|
|
|
|
|
|
|
// 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
|
2018-10-20 22:42:49 +00:00
|
|
|
)
|