Compare commits
No commits in common. "902ed33ee4907fa55f1c3430bd6e53c113288646" and "e7c2ae657f945896db21f3085ad8759c07c04a86" have entirely different histories.
902ed33ee4
...
e7c2ae657f
13 changed files with 40 additions and 404 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.3 KiB |
|
|
@ -1,89 +0,0 @@
|
||||||
extends Node
|
|
||||||
|
|
||||||
# Autoloaded as "PixelScreen". The game draws into a fixed 640x480 screen (the
|
|
||||||
# viewport size in Project Settings), which is scaled to fit the window as big
|
|
||||||
# as it can go while keeping its shape, with black bars filling the rest.
|
|
||||||
# It scales smoothly to any size, and the sharp_bilinear shader keeps the pixels
|
|
||||||
# crisp and all the same size.
|
|
||||||
#
|
|
||||||
# The scene being played, and the Transition overlay, live inside the screen.
|
|
||||||
# Change scenes with change_scene() / reload_scene() (Transition does this),
|
|
||||||
# not get_tree().change_scene_to_file(), which would put the new scene outside it.
|
|
||||||
# get_tree().current_scene is null once the game is running: Godot only allows
|
|
||||||
# it to be a direct child of the window. Use PixelScreen.scene instead.
|
|
||||||
|
|
||||||
var screen := SubViewport.new()
|
|
||||||
var scene: Node # The scene being played.
|
|
||||||
var _container := SubViewportContainer.new()
|
|
||||||
var _bars := ColorRect.new()
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
# Keeps passing input to the screen while the game is paused, so the pause
|
|
||||||
# menu works. The game itself pauses as normal.
|
|
||||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
|
||||||
|
|
||||||
_bars.color = Color.BLACK
|
|
||||||
_bars.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
||||||
add_child(_bars)
|
|
||||||
|
|
||||||
screen.size = Vector2i(
|
|
||||||
ProjectSettings.get_setting("display/window/size/viewport_width"),
|
|
||||||
ProjectSettings.get_setting("display/window/size/viewport_height"))
|
|
||||||
screen.process_mode = Node.PROCESS_MODE_PAUSABLE
|
|
||||||
screen.render_target_update_mode = SubViewport.UPDATE_ALWAYS
|
|
||||||
screen.handle_input_locally = false
|
|
||||||
screen.canvas_item_default_texture_filter = Viewport.DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST
|
|
||||||
screen.snap_2d_transforms_to_pixel = true
|
|
||||||
screen.audio_listener_enable_2d = true
|
|
||||||
|
|
||||||
_container.stretch = false
|
|
||||||
_container.size = screen.size
|
|
||||||
_container.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR # The shader needs it.
|
|
||||||
var material := ShaderMaterial.new()
|
|
||||||
material.shader = preload("res://Autoloads/sharp_bilinear.gdshader")
|
|
||||||
_container.material = material
|
|
||||||
_container.add_child(screen)
|
|
||||||
add_child(_container)
|
|
||||||
|
|
||||||
get_window().size_changed.connect(_fit_to_window)
|
|
||||||
_fit_to_window()
|
|
||||||
# The main scene is added after the autoloads, so move it in once it's there.
|
|
||||||
_adopt_scenes.call_deferred()
|
|
||||||
|
|
||||||
|
|
||||||
# Swaps the scene being played for the one at `path`.
|
|
||||||
func change_scene(path: String) -> void:
|
|
||||||
_swap_to.call_deferred(load(path))
|
|
||||||
|
|
||||||
|
|
||||||
func reload_scene() -> void:
|
|
||||||
if scene != null and not scene.scene_file_path.is_empty():
|
|
||||||
change_scene(scene.scene_file_path)
|
|
||||||
|
|
||||||
|
|
||||||
func _adopt_scenes() -> void:
|
|
||||||
Transition.reparent(screen, false)
|
|
||||||
scene = get_tree().current_scene
|
|
||||||
if scene != null:
|
|
||||||
scene.reparent(screen, false)
|
|
||||||
screen.move_child(scene, 0) # Under the Transition overlay.
|
|
||||||
|
|
||||||
|
|
||||||
func _swap_to(packed: PackedScene) -> void:
|
|
||||||
if is_instance_valid(scene):
|
|
||||||
scene.get_parent().remove_child(scene)
|
|
||||||
scene.queue_free()
|
|
||||||
scene = packed.instantiate()
|
|
||||||
screen.add_child(scene)
|
|
||||||
screen.move_child(scene, 0) # Under the Transition overlay.
|
|
||||||
|
|
||||||
|
|
||||||
# Scales the screen as big as fits in the window, keeping its shape, centred.
|
|
||||||
func _fit_to_window() -> void:
|
|
||||||
var windowSize := Vector2(get_window().size)
|
|
||||||
var screenSize := Vector2(screen.size)
|
|
||||||
var scale := minf(windowSize.x / screenSize.x, windowSize.y / screenSize.y)
|
|
||||||
_bars.size = windowSize
|
|
||||||
_container.scale = Vector2.ONE * scale
|
|
||||||
_container.position = ((windowSize - screenSize * scale) / 2.0).round()
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://btqewdah127eg
|
|
||||||
|
|
@ -10,17 +10,13 @@ const SAVE_PATH = "user://settings.cfg"
|
||||||
|
|
||||||
# Which input actions show up in the Controls tab. "pause" is left out on
|
# Which input actions show up in the Controls tab. "pause" is left out on
|
||||||
# purpose so the player can't lose the key that opens the menu.
|
# purpose so the player can't lose the key that opens the menu.
|
||||||
const REBINDABLE_ACTIONS = ["moveLeft", "moveRight", "moveUp", "moveDown"]
|
const REBINDABLE_ACTIONS = ["moveLeft", "moveRight", "moveUp", "moveDown", "jump"]
|
||||||
|
|
||||||
# Audio bus names, as set up in the Audio tab at the bottom of the editor.
|
# Audio bus names, as set up in the Audio tab at the bottom of the editor.
|
||||||
const VOLUME_BUSES = ["Master", "Music", "SFX"]
|
const VOLUME_BUSES = ["Master", "Music", "SFX"]
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
load_settings()
|
load_settings()
|
||||||
# Don't let the window be dragged smaller than the game's 640x480 view.
|
|
||||||
get_window().min_size = Vector2i(
|
|
||||||
ProjectSettings.get_setting("display/window/size/viewport_width"),
|
|
||||||
ProjectSettings.get_setting("display/window/size/viewport_height"))
|
|
||||||
|
|
||||||
func save_settings() -> void:
|
func save_settings() -> void:
|
||||||
var config := ConfigFile.new()
|
var config := ConfigFile.new()
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
shader_type canvas_item;
|
|
||||||
|
|
||||||
// "Sharp bilinear" upscaling for pixel art, used by PixelScreen.
|
|
||||||
// Each game pixel is drawn as a solid block, and only the single screen pixel
|
|
||||||
// where two game pixels meet is blended. So the game can be scaled by any
|
|
||||||
// amount (2.25x, 3.7x...) with every pixel looking the same size, instead of
|
|
||||||
// some being drawn a screen pixel wider than others.
|
|
||||||
// Needs the texture to be sampled with linear filtering.
|
|
||||||
|
|
||||||
void fragment() {
|
|
||||||
vec2 textureSize = 1.0 / TEXTURE_PIXEL_SIZE;
|
|
||||||
vec2 texel = UV * textureSize;
|
|
||||||
// How many screen pixels one game pixel covers.
|
|
||||||
vec2 scale = 1.0 / max(fwidth(texel), vec2(1e-5));
|
|
||||||
// Inside this distance of a game pixel's centre, show its colour as is.
|
|
||||||
vec2 solid = max(0.5 - 0.5 / scale, vec2(0.0));
|
|
||||||
vec2 fromCentre = fract(texel) - 0.5;
|
|
||||||
vec2 blend = (fromCentre - clamp(fromCentre, -solid, solid)) * scale + 0.5;
|
|
||||||
COLOR = texture(TEXTURE, (floor(texel) + blend) / textureSize);
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://doxlp8ex7ruwr
|
|
||||||
|
|
@ -38,12 +38,11 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||||
and not event.echo and event.keycode == KEY_F9:
|
and not event.echo and event.keycode == KEY_F9:
|
||||||
reload_scene()
|
reload_scene()
|
||||||
|
|
||||||
# Scenes are swapped by PixelScreen, so they're drawn inside its 640x480 screen.
|
|
||||||
func change_scene(path: String) -> void:
|
func change_scene(path: String) -> void:
|
||||||
_dissolve(func(): PixelScreen.change_scene(path))
|
_dissolve(func(): get_tree().change_scene_to_file(path))
|
||||||
|
|
||||||
func reload_scene() -> void:
|
func reload_scene() -> void:
|
||||||
_dissolve(func(): PixelScreen.reload_scene())
|
_dissolve(func(): get_tree().reload_current_scene())
|
||||||
|
|
||||||
func _dissolve(swap_scene: Callable) -> void:
|
func _dissolve(swap_scene: Callable) -> void:
|
||||||
if busy: return
|
if busy: return
|
||||||
|
|
|
||||||
|
|
@ -74,16 +74,6 @@ const REST_FRAME = 0 # The Idle animation's frame. We reform as it.
|
||||||
const PRESS_WALL_FRAME = 9
|
const PRESS_WALL_FRAME = 9
|
||||||
const PRESS_WALL_SPRITE_SHIFT = 6.0
|
const PRESS_WALL_SPRITE_SHIFT = 6.0
|
||||||
|
|
||||||
# Holding away from a surface with another facing it one tile across makes us
|
|
||||||
# stretch between the two (a bridge) instead of hopping: wall to wall, or floor
|
|
||||||
# to ceiling. The Bridge and BridgeVertical animations' frames are columns
|
|
||||||
# exactly that long, always drawn the same way round and centred between the
|
|
||||||
# surfaces (see _align_press_wall_sprite).
|
|
||||||
const BRIDGE_FRAME = 10 # Wall to wall. Drawn upright, so it's turned a quarter.
|
|
||||||
const BRIDGE_VERTICAL_FRAME = 11 # Floor to ceiling.
|
|
||||||
const BRIDGE_GAP = 32.0 # One tile.
|
|
||||||
const BRIDGE_GAP_TOLERANCE = 1.5
|
|
||||||
|
|
||||||
###############
|
###############
|
||||||
## Variables ##
|
## Variables ##
|
||||||
###############
|
###############
|
||||||
|
|
@ -145,14 +135,6 @@ var timeSpentSqueezingIntoTube := 0.0
|
||||||
var tubeLayers: Array[TileMapLayer] = [] # TileMapLayers whose tiles can be tubes.
|
var tubeLayers: Array[TileMapLayer] = [] # TileMapLayers whose tiles can be tubes.
|
||||||
var hasFoundTubeLayers := false
|
var hasFoundTubeLayers := false
|
||||||
|
|
||||||
# Stretched across a one-tile gap between two walls, or a floor and a ceiling.
|
|
||||||
# We're stuck to neither as far as the rest of the movement code knows; holding
|
|
||||||
# towards one for HOLD_TIME lets go of the other (see _update_bridge).
|
|
||||||
var isBridging := false
|
|
||||||
var bridgeAxis := Vector2.RIGHT # RIGHT between walls, DOWN between floor and ceiling.
|
|
||||||
var bridgeHoldSide := 0.0 # Which way along bridgeAxis we're holding (1, -1), or 0.
|
|
||||||
var timeSpentLeavingBridge := 0.0
|
|
||||||
|
|
||||||
var carriedItem: CarryItem = null # The item riding in our center, or null. Tubes drop it.
|
var carriedItem: CarryItem = null # The item riding in our center, or null. Tubes drop it.
|
||||||
|
|
||||||
###########
|
###########
|
||||||
|
|
@ -204,11 +186,7 @@ func _ready() -> void:
|
||||||
# they reform as from the sprite's offset, and that must not carry the shift.
|
# they reform as from the sprite's offset, and that must not carry the shift.
|
||||||
func _align_press_wall_sprite() -> void:
|
func _align_press_wall_sprite() -> void:
|
||||||
var targetPosition := spriteBasePosition
|
var targetPosition := spriteBasePosition
|
||||||
if sprite.frame == BRIDGE_FRAME or sprite.frame == BRIDGE_VERTICAL_FRAME:
|
if sprite.frame == PRESS_WALL_FRAME:
|
||||||
# The sprite's offset lifts it off the surface we're on. Undo that so the
|
|
||||||
# column sits centred on us, between the surfaces.
|
|
||||||
targetPosition -= sprite.offset.rotated(sprite.rotation).round()
|
|
||||||
elif sprite.frame == PRESS_WALL_FRAME:
|
|
||||||
# Towards the frame's right (away from its wall), turned with the sprite.
|
# Towards the frame's right (away from its wall), turned with the sprite.
|
||||||
var awayFromWall := Vector2(-1.0 if sprite.flip_h else 1.0, 0.0).rotated(sprite.rotation).round()
|
var awayFromWall := Vector2(-1.0 if sprite.flip_h else 1.0, 0.0).rotated(sprite.rotation).round()
|
||||||
targetPosition += awayFromWall * PRESS_WALL_SPRITE_SHIFT
|
targetPosition += awayFromWall * PRESS_WALL_SPRITE_SHIFT
|
||||||
|
|
@ -226,9 +204,6 @@ func _physics_process(delta: float) -> void:
|
||||||
if isWrapping:
|
if isWrapping:
|
||||||
_update_wrap(delta)
|
_update_wrap(delta)
|
||||||
return
|
return
|
||||||
if isBridging:
|
|
||||||
_update_bridge(delta, moveInput)
|
|
||||||
return
|
|
||||||
tubeReentryCooldown = maxf(tubeReentryCooldown - delta, 0.0)
|
tubeReentryCooldown = maxf(tubeReentryCooldown - delta, 0.0)
|
||||||
|
|
||||||
var wasInAir := (_get_surface_normal() == Vector2.ZERO)
|
var wasInAir := (_get_surface_normal() == Vector2.ZERO)
|
||||||
|
|
@ -249,8 +224,6 @@ func _physics_process(delta: float) -> void:
|
||||||
_update_vertical_movement(delta, moveInput)
|
_update_vertical_movement(delta, moveInput)
|
||||||
_update_floor_hop(delta, moveInput)
|
_update_floor_hop(delta, moveInput)
|
||||||
_update_horizontal_movement(delta, moveInput)
|
_update_horizontal_movement(delta, moveInput)
|
||||||
if isBridging: # Just started one.
|
|
||||||
return
|
|
||||||
_hold_at_edge(delta)
|
_hold_at_edge(delta)
|
||||||
|
|
||||||
var wasOnWall := (isStickingToWall and not is_on_floor())
|
var wasOnWall := (isStickingToWall and not is_on_floor())
|
||||||
|
|
@ -300,15 +273,6 @@ func _update_facing(moveInput: Vector2) -> void:
|
||||||
# Facts the AnimationTree's state machine reads to pick an animation (see the
|
# Facts the AnimationTree's state machine reads to pick an animation (see the
|
||||||
# transitions' advance expressions in player.tscn).
|
# transitions' advance expressions in player.tscn).
|
||||||
func _update_animation_conditions(moveInput: Vector2) -> void:
|
func _update_animation_conditions(moveInput: Vector2) -> void:
|
||||||
if isBridging:
|
|
||||||
# Only "not isBridging" leaves the Bridge state, but keep the rest quiet anyway.
|
|
||||||
isOnSurface = true
|
|
||||||
isCrawling = false
|
|
||||||
isHoldingAtEdge = false
|
|
||||||
isPressingIntoSurface = false
|
|
||||||
isPressingWall = false
|
|
||||||
isReachingAway = false
|
|
||||||
return
|
|
||||||
isOnSurface = _get_surface_normal() != Vector2.ZERO
|
isOnSurface = _get_surface_normal() != Vector2.ZERO
|
||||||
isPressingWall = _get_pressed_wall_direction(moveInput) != Vector2.ZERO
|
isPressingWall = _get_pressed_wall_direction(moveInput) != Vector2.ZERO
|
||||||
isCrawling = ((moveInput.x != 0.0 and (isStickingToCeiling or is_on_floor()))
|
isCrawling = ((moveInput.x != 0.0 and (isStickingToCeiling or is_on_floor()))
|
||||||
|
|
@ -344,8 +308,6 @@ func _update_ceiling_letting_go(delta: float, moveInput: Vector2) -> void:
|
||||||
velocity.y = -CEILING_STICK_SPEED
|
velocity.y = -CEILING_STICK_SPEED
|
||||||
return
|
return
|
||||||
|
|
||||||
if _try_begin_bridge(Vector2.DOWN):
|
|
||||||
return
|
|
||||||
isStickingToCeiling = false
|
isStickingToCeiling = false
|
||||||
var floorDistance := _get_hop_distance(Vector2.DOWN)
|
var floorDistance := _get_hop_distance(Vector2.DOWN)
|
||||||
if floorDistance >= 0.0:
|
if floorDistance >= 0.0:
|
||||||
|
|
@ -362,8 +324,6 @@ func _update_floor_hop(delta: float, moveInput: Vector2) -> void:
|
||||||
|
|
||||||
if timeSpentHoldingUpOnFloor >= HOLD_TIME:
|
if timeSpentHoldingUpOnFloor >= HOLD_TIME:
|
||||||
timeSpentHoldingUpOnFloor = 0.0
|
timeSpentHoldingUpOnFloor = 0.0
|
||||||
if _try_begin_bridge(Vector2.UP):
|
|
||||||
return
|
|
||||||
velocity.y = -_get_hop_speed(_get_hop_height())
|
velocity.y = -_get_hop_speed(_get_hop_height())
|
||||||
|
|
||||||
func _update_horizontal_movement(delta: float, moveInput: Vector2) -> void:
|
func _update_horizontal_movement(delta: float, moveInput: Vector2) -> void:
|
||||||
|
|
@ -377,8 +337,8 @@ func _update_horizontal_movement(delta: float, moveInput: Vector2) -> void:
|
||||||
elif not isHoppingAcross:
|
elif not isHoppingAcross:
|
||||||
velocity.x = _air_steer(velocity.x, moveInput.x, delta)
|
velocity.x = _air_steer(velocity.x, moveInput.x, delta)
|
||||||
|
|
||||||
# Holding away (not climbing) for HOLD_TIME bridges to the opposite wall if it's
|
# Holding away (not climbing) for HOLD_TIME hops to the opposite wall if one's
|
||||||
# one tile across, hops to it if it's further but in reach, otherwise lets go.
|
# in reach, otherwise lets go.
|
||||||
func _update_wall_letting_go(delta: float, moveInput: Vector2) -> void:
|
func _update_wall_letting_go(delta: float, moveInput: Vector2) -> void:
|
||||||
var pressingAwayFromWall := moveInput.x * wallNormalX > 0
|
var pressingAwayFromWall := moveInput.x * wallNormalX > 0
|
||||||
if not pressingAwayFromWall:
|
if not pressingAwayFromWall:
|
||||||
|
|
@ -394,9 +354,6 @@ func _update_wall_letting_go(delta: float, moveInput: Vector2) -> void:
|
||||||
velocity.x = -wallNormalX * WALL_STICK_SPEED
|
velocity.x = -wallNormalX * WALL_STICK_SPEED
|
||||||
return
|
return
|
||||||
|
|
||||||
if _try_begin_bridge(Vector2(wallNormalX, 0)):
|
|
||||||
return
|
|
||||||
|
|
||||||
var wallDistance := _get_hop_distance(Vector2(wallNormalX, 0))
|
var wallDistance := _get_hop_distance(Vector2(wallNormalX, 0))
|
||||||
if wallDistance >= 0.0:
|
if wallDistance >= 0.0:
|
||||||
_hop_across(wallDistance)
|
_hop_across(wallDistance)
|
||||||
|
|
@ -584,115 +541,6 @@ func _hop_across(distance: float) -> void:
|
||||||
isHoppingAcross = true
|
isHoppingAcross = true
|
||||||
|
|
||||||
|
|
||||||
# ---- Bridges ----
|
|
||||||
|
|
||||||
# Bridges from the surface we're on (facing `normal`) to one facing it
|
|
||||||
# BRIDGE_GAP across, if there is one. Returns whether it did.
|
|
||||||
func _try_begin_bridge(normal: Vector2) -> bool:
|
|
||||||
var surfaces := _find_bridge_surfaces(normal)
|
|
||||||
if surfaces.is_empty():
|
|
||||||
return false
|
|
||||||
_begin_bridge(normal, surfaces.own, surfaces.other)
|
|
||||||
return true
|
|
||||||
|
|
||||||
|
|
||||||
# Where the surface we're on (facing `normal`) and the one across from it are,
|
|
||||||
# if that's BRIDGE_GAP away and faces us all across our width: {own, other}
|
|
||||||
# (points on each). Otherwise empty.
|
|
||||||
func _find_bridge_surfaces(normal: Vector2) -> Dictionary:
|
|
||||||
var reach := BRIDGE_GAP + BRIDGE_GAP_TOLERANCE
|
|
||||||
var across := normal.orthogonal()
|
|
||||||
var radius := _get_radius()
|
|
||||||
var surfaces := {}
|
|
||||||
for offset: float in [-radius * 0.5, 0.0, radius * 0.5]:
|
|
||||||
var from := global_position + across * offset
|
|
||||||
var ownHit := _cast_ray(from, from - normal * reach)
|
|
||||||
var otherHit := _cast_ray(from, from + normal * reach)
|
|
||||||
if ownHit.is_empty() or otherHit.is_empty():
|
|
||||||
return {}
|
|
||||||
if ownHit.normal.dot(normal) < 0.9 or otherHit.normal.dot(-normal) < 0.9:
|
|
||||||
return {}
|
|
||||||
var gap := absf((otherHit.position - ownHit.position).dot(normal))
|
|
||||||
if absf(gap - BRIDGE_GAP) > BRIDGE_GAP_TOLERANCE:
|
|
||||||
return {}
|
|
||||||
surfaces = {own = ownHit.position, other = otherHit.position}
|
|
||||||
return surfaces
|
|
||||||
|
|
||||||
|
|
||||||
func _begin_bridge(normal: Vector2, ownPoint: Vector2, otherPoint: Vector2) -> void:
|
|
||||||
isBridging = true
|
|
||||||
bridgeAxis = Vector2.RIGHT if absf(normal.x) > 0.5 else Vector2.DOWN
|
|
||||||
isStickingToWall = false
|
|
||||||
isStickingToCeiling = false
|
|
||||||
isHoppingAcross = false
|
|
||||||
timeSpentUnstickingWall = 0.0
|
|
||||||
timeSpentUnstickingCeiling = 0.0
|
|
||||||
timeSpentHoldingUpOnFloor = 0.0
|
|
||||||
timeSpentHoldingEdge = 0.0
|
|
||||||
timeSpentLeavingBridge = 0.0
|
|
||||||
# We're still holding away from the surface we left, towards the one across.
|
|
||||||
# Keep holding and we cross over to it after HOLD_TIME, like any other hold.
|
|
||||||
bridgeHoldSide = signf(normal.dot(bridgeAxis))
|
|
||||||
velocity = Vector2.ZERO
|
|
||||||
|
|
||||||
# Halfway between the surfaces, staying put the other way.
|
|
||||||
var middle := (ownPoint + otherPoint) / 2.0
|
|
||||||
global_position += bridgeAxis * (middle - global_position).dot(bridgeAxis)
|
|
||||||
# Always drawn the same way round, whichever surface we came from, unflipped.
|
|
||||||
# Between walls, turned as for the left wall, which puts the frame's flat
|
|
||||||
# side on top. Between floor and ceiling, upright.
|
|
||||||
sprite.flip_h = false
|
|
||||||
if bridgeAxis == Vector2.RIGHT:
|
|
||||||
_set_sprite_rotation(_rotation_for(Vector2.RIGHT))
|
|
||||||
_show_pose(&"Bridge", BRIDGE_FRAME)
|
|
||||||
else:
|
|
||||||
_set_sprite_rotation(0.0)
|
|
||||||
_show_pose(&"BridgeVertical", BRIDGE_VERTICAL_FRAME)
|
|
||||||
|
|
||||||
|
|
||||||
# Holding towards either surface for HOLD_TIME sticks us to it and lets go of
|
|
||||||
# the other: left or right between walls, up or down between floor and ceiling.
|
|
||||||
func _update_bridge(delta: float, moveInput: Vector2) -> void:
|
|
||||||
velocity = Vector2.ZERO
|
|
||||||
var inputDirection := Vector2(moveInput.x, -moveInput.y) # Up is negative y.
|
|
||||||
var side := signf(inputDirection.dot(bridgeAxis))
|
|
||||||
if side != 0.0 and side == bridgeHoldSide:
|
|
||||||
timeSpentLeavingBridge += delta
|
|
||||||
else:
|
|
||||||
timeSpentLeavingBridge = 0.0
|
|
||||||
bridgeHoldSide = side
|
|
||||||
|
|
||||||
if timeSpentLeavingBridge >= HOLD_TIME:
|
|
||||||
_leave_bridge(bridgeAxis * side, delta)
|
|
||||||
|
|
||||||
|
|
||||||
# Sticks to the surface in `direction` from us.
|
|
||||||
func _leave_bridge(direction: Vector2, delta: float) -> void:
|
|
||||||
isBridging = false
|
|
||||||
timeSpentLeavingBridge = 0.0
|
|
||||||
var normal := -direction
|
|
||||||
var gap := BRIDGE_GAP / 2.0 - _get_radius()
|
|
||||||
_set_sprite_rotation(_rotation_for(normal))
|
|
||||||
_settle_onto_surface(normal, gap, delta)
|
|
||||||
velocity = Vector2.ZERO
|
|
||||||
# Holding towards the surface we're now on isn't holding away from it, so
|
|
||||||
# there's nothing to ignore until release.
|
|
||||||
ignoreWallUnstickUntilRelease = false
|
|
||||||
ignoreCeilingUnstickUntilRelease = false
|
|
||||||
_show_pose(&"Idle", REST_FRAME)
|
|
||||||
|
|
||||||
|
|
||||||
# Jumps straight to an animation state, showing its frame now rather than when
|
|
||||||
# the AnimationTree next updates. Our body jumped too: don't smooth it.
|
|
||||||
func _show_pose(state: StringName, frame: int) -> void:
|
|
||||||
reset_physics_interpolation()
|
|
||||||
sprite.frame = frame
|
|
||||||
_align_press_wall_sprite()
|
|
||||||
_update_animation_conditions(Vector2.ZERO)
|
|
||||||
var playback: AnimationNodeStateMachinePlayback = animationTree.get("parameters/playback")
|
|
||||||
playback.start(state)
|
|
||||||
|
|
||||||
|
|
||||||
# ---- Edges ----
|
# ---- Edges ----
|
||||||
|
|
||||||
# Pressing into the surface near an edge starts wrapping around it. A direction
|
# Pressing into the surface near an edge starts wrapping around it. A direction
|
||||||
|
|
|
||||||
|
|
@ -12,40 +12,6 @@
|
||||||
[sub_resource type="Gradient" id="Gradient_splat"]
|
[sub_resource type="Gradient" id="Gradient_splat"]
|
||||||
colors = PackedColorArray(0, 0.6666667, 0, 1, 0, 1, 0.50980395, 1)
|
colors = PackedColorArray(0, 0.6666667, 0, 1, 0, 1, 0.50980395, 1)
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_Bridge"]
|
|
||||||
resource_name = "Bridge"
|
|
||||||
length = 0.2
|
|
||||||
loop_mode = 1
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath("Sprite2D:frame")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 1,
|
|
||||||
"values": [10]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_BridgeVertical"]
|
|
||||||
resource_name = "BridgeVertical"
|
|
||||||
length = 0.2
|
|
||||||
loop_mode = 1
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath("Sprite2D:frame")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 1,
|
|
||||||
"values": [11]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_Crouch"]
|
[sub_resource type="Animation" id="Animation_Crouch"]
|
||||||
resource_name = "Crouch"
|
resource_name = "Crouch"
|
||||||
length = 0.4
|
length = 0.4
|
||||||
|
|
@ -113,23 +79,6 @@ tracks/0/keys = {
|
||||||
"values": [0, 1, 2, 1]
|
"values": [0, 1, 2, 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_PressWall"]
|
|
||||||
resource_name = "PressWall"
|
|
||||||
length = 0.2
|
|
||||||
loop_mode = 1
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath("Sprite2D:frame")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 1,
|
|
||||||
"values": [9]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_4m0gv"]
|
[sub_resource type="Animation" id="Animation_4m0gv"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
|
|
@ -178,10 +127,25 @@ tracks/0/keys = {
|
||||||
"values": [4, 5]
|
"values": [4, 5]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_PressWall"]
|
||||||
|
resource_name = "PressWall"
|
||||||
|
length = 0.2
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [9]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_slime"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_slime"]
|
||||||
_data = {
|
_data = {
|
||||||
&"Bridge": SubResource("Animation_Bridge"),
|
|
||||||
&"BridgeVertical": SubResource("Animation_BridgeVertical"),
|
|
||||||
&"Crouch": SubResource("Animation_Crouch"),
|
&"Crouch": SubResource("Animation_Crouch"),
|
||||||
&"Idle": SubResource("Animation_Idle"),
|
&"Idle": SubResource("Animation_Idle"),
|
||||||
&"InAir": SubResource("Animation_InAir"),
|
&"InAir": SubResource("Animation_InAir"),
|
||||||
|
|
@ -192,12 +156,6 @@ _data = {
|
||||||
&"ReachY": SubResource("Animation_ReachY")
|
&"ReachY": SubResource("Animation_ReachY")
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeAnimation" id="AnimNode_Bridge"]
|
|
||||||
animation = &"Bridge"
|
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeAnimation" id="AnimNode_BridgeVertical"]
|
|
||||||
animation = &"BridgeVertical"
|
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeAnimation" id="AnimNode_Crouch"]
|
[sub_resource type="AnimationNodeAnimation" id="AnimNode_Crouch"]
|
||||||
animation = &"Crouch"
|
animation = &"Crouch"
|
||||||
|
|
||||||
|
|
@ -390,19 +348,7 @@ advance_expression = "isReachingAway and not isCrawling and not isHoldingAtEdge
|
||||||
advance_mode = 2
|
advance_mode = 2
|
||||||
advance_expression = "isPressingIntoSurface and not isCrawling and not isHoldingAtEdge"
|
advance_expression = "isPressingIntoSurface and not isCrawling and not isHoldingAtEdge"
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeStateMachineTransition" id="Transition_Bridge_Idle"]
|
|
||||||
advance_mode = 2
|
|
||||||
advance_expression = "not isBridging"
|
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeStateMachineTransition" id="Transition_BridgeVertical_Idle"]
|
|
||||||
advance_mode = 2
|
|
||||||
advance_expression = "not isBridging"
|
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_slime"]
|
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_slime"]
|
||||||
states/BridgeVertical/node = SubResource("AnimNode_BridgeVertical")
|
|
||||||
states/BridgeVertical/position = Vector2(1150, 300)
|
|
||||||
states/Bridge/node = SubResource("AnimNode_Bridge")
|
|
||||||
states/Bridge/position = Vector2(900, 300)
|
|
||||||
states/Crouch/node = SubResource("AnimNode_Crouch")
|
states/Crouch/node = SubResource("AnimNode_Crouch")
|
||||||
states/Crouch/position = Vector2(150, 300)
|
states/Crouch/position = Vector2(150, 300)
|
||||||
states/Idle/node = SubResource("AnimNode_Idle")
|
states/Idle/node = SubResource("AnimNode_Idle")
|
||||||
|
|
@ -418,7 +364,7 @@ states/ReachX/position = Vector2(650, 300)
|
||||||
states/ReachY/node = SubResource("AnimNode_ReachY")
|
states/ReachY/node = SubResource("AnimNode_ReachY")
|
||||||
states/ReachY/position = Vector2(400, 300)
|
states/ReachY/position = Vector2(400, 300)
|
||||||
states/Start/position = Vector2(150, 100)
|
states/Start/position = Vector2(150, 100)
|
||||||
transitions = ["Start", "Idle", SubResource("Transition_Start"), "Idle", "Moving", SubResource("Transition_Idle_Moving"), "Idle", "InAir", SubResource("Transition_Idle_InAir"), "Idle", "ReachX", SubResource("Transition_Idle_ReachX"), "Idle", "ReachY", SubResource("Transition_Idle_ReachY"), "Idle", "Crouch", SubResource("Transition_Idle_Crouch"), "Moving", "Idle", SubResource("Transition_Moving_Idle"), "Moving", "InAir", SubResource("Transition_Moving_InAir"), "Moving", "ReachX", SubResource("Transition_Moving_ReachX"), "Moving", "ReachY", SubResource("Transition_Moving_ReachY"), "Moving", "Crouch", SubResource("Transition_Moving_Crouch"), "InAir", "Idle", SubResource("Transition_InAir_Idle"), "InAir", "Moving", SubResource("Transition_InAir_Moving"), "InAir", "ReachX", SubResource("Transition_InAir_ReachX"), "InAir", "ReachY", SubResource("Transition_InAir_ReachY"), "InAir", "Crouch", SubResource("Transition_InAir_Crouch"), "ReachX", "Idle", SubResource("Transition_ReachX_Idle"), "ReachX", "Moving", SubResource("Transition_ReachX_Moving"), "ReachX", "InAir", SubResource("Transition_ReachX_InAir"), "ReachX", "ReachY", SubResource("Transition_ReachX_ReachY"), "ReachX", "Crouch", SubResource("Transition_ReachX_Crouch"), "ReachY", "Idle", SubResource("Transition_ReachY_Idle"), "ReachY", "Moving", SubResource("Transition_ReachY_Moving"), "ReachY", "InAir", SubResource("Transition_ReachY_InAir"), "ReachY", "ReachX", SubResource("Transition_ReachY_ReachX"), "ReachY", "Crouch", SubResource("Transition_ReachY_Crouch"), "Crouch", "Idle", SubResource("Transition_Crouch_Idle"), "Crouch", "Moving", SubResource("Transition_Crouch_Moving"), "Crouch", "InAir", SubResource("Transition_Crouch_InAir"), "Crouch", "ReachX", SubResource("Transition_Crouch_ReachX"), "Crouch", "ReachY", SubResource("Transition_Crouch_ReachY"), "Idle", "PressWall", SubResource("Transition_Idle_PressWall"), "Moving", "PressWall", SubResource("Transition_Moving_PressWall"), "InAir", "PressWall", SubResource("Transition_InAir_PressWall"), "ReachX", "PressWall", SubResource("Transition_ReachX_PressWall"), "ReachY", "PressWall", SubResource("Transition_ReachY_PressWall"), "Crouch", "PressWall", SubResource("Transition_Crouch_PressWall"), "PressWall", "Idle", SubResource("Transition_PressWall_Idle"), "PressWall", "Moving", SubResource("Transition_PressWall_Moving"), "PressWall", "InAir", SubResource("Transition_PressWall_InAir"), "PressWall", "ReachX", SubResource("Transition_PressWall_ReachX"), "PressWall", "ReachY", SubResource("Transition_PressWall_ReachY"), "PressWall", "Crouch", SubResource("Transition_PressWall_Crouch"), "Bridge", "Idle", SubResource("Transition_Bridge_Idle"), "BridgeVertical", "Idle", SubResource("Transition_BridgeVertical_Idle")]
|
transitions = ["Start", "Idle", SubResource("Transition_Start"), "Idle", "Moving", SubResource("Transition_Idle_Moving"), "Idle", "InAir", SubResource("Transition_Idle_InAir"), "Idle", "ReachX", SubResource("Transition_Idle_ReachX"), "Idle", "ReachY", SubResource("Transition_Idle_ReachY"), "Idle", "Crouch", SubResource("Transition_Idle_Crouch"), "Moving", "Idle", SubResource("Transition_Moving_Idle"), "Moving", "InAir", SubResource("Transition_Moving_InAir"), "Moving", "ReachX", SubResource("Transition_Moving_ReachX"), "Moving", "ReachY", SubResource("Transition_Moving_ReachY"), "Moving", "Crouch", SubResource("Transition_Moving_Crouch"), "InAir", "Idle", SubResource("Transition_InAir_Idle"), "InAir", "Moving", SubResource("Transition_InAir_Moving"), "InAir", "ReachX", SubResource("Transition_InAir_ReachX"), "InAir", "ReachY", SubResource("Transition_InAir_ReachY"), "InAir", "Crouch", SubResource("Transition_InAir_Crouch"), "ReachX", "Idle", SubResource("Transition_ReachX_Idle"), "ReachX", "Moving", SubResource("Transition_ReachX_Moving"), "ReachX", "InAir", SubResource("Transition_ReachX_InAir"), "ReachX", "ReachY", SubResource("Transition_ReachX_ReachY"), "ReachX", "Crouch", SubResource("Transition_ReachX_Crouch"), "ReachY", "Idle", SubResource("Transition_ReachY_Idle"), "ReachY", "Moving", SubResource("Transition_ReachY_Moving"), "ReachY", "InAir", SubResource("Transition_ReachY_InAir"), "ReachY", "ReachX", SubResource("Transition_ReachY_ReachX"), "ReachY", "Crouch", SubResource("Transition_ReachY_Crouch"), "Crouch", "Idle", SubResource("Transition_Crouch_Idle"), "Crouch", "Moving", SubResource("Transition_Crouch_Moving"), "Crouch", "InAir", SubResource("Transition_Crouch_InAir"), "Crouch", "ReachX", SubResource("Transition_Crouch_ReachX"), "Crouch", "ReachY", SubResource("Transition_Crouch_ReachY"), "Idle", "PressWall", SubResource("Transition_Idle_PressWall"), "Moving", "PressWall", SubResource("Transition_Moving_PressWall"), "InAir", "PressWall", SubResource("Transition_InAir_PressWall"), "ReachX", "PressWall", SubResource("Transition_ReachX_PressWall"), "ReachY", "PressWall", SubResource("Transition_ReachY_PressWall"), "Crouch", "PressWall", SubResource("Transition_Crouch_PressWall"), "PressWall", "Idle", SubResource("Transition_PressWall_Idle"), "PressWall", "Moving", SubResource("Transition_PressWall_Moving"), "PressWall", "InAir", SubResource("Transition_PressWall_InAir"), "PressWall", "ReachX", SubResource("Transition_PressWall_ReachX"), "PressWall", "ReachY", SubResource("Transition_PressWall_ReachY"), "PressWall", "Crouch", SubResource("Transition_PressWall_Crouch")]
|
||||||
graph_offset = Vector2(0, -150)
|
graph_offset = Vector2(0, -150)
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody2D" unique_id=150873177]
|
[node name="Player" type="CharacterBody2D" unique_id=150873177]
|
||||||
|
|
@ -428,7 +374,7 @@ landSounds = Array[AudioStream]([ExtResource("3_land1"), ExtResource("4_land2"),
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=402647784]
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=402647784]
|
||||||
texture = ExtResource("5_4m0gv")
|
texture = ExtResource("5_4m0gv")
|
||||||
offset = Vector2(0, -6)
|
offset = Vector2(0, -6)
|
||||||
hframes = 12
|
hframes = 10
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1379572123]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1379572123]
|
||||||
shape = SubResource("CircleShape2D_eovys")
|
shape = SubResource("CircleShape2D_eovys")
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,6 @@ extends Node2D
|
||||||
# Pixels keep their colours on the way, and blend into the colour of the spot
|
# Pixels keep their colours on the way, and blend into the colour of the spot
|
||||||
# they land on, so the sprite reforms exactly.
|
# they land on, so the sprite reforms exactly.
|
||||||
# Watch isFinished to know when every pixel is back in place.
|
# Watch isFinished to know when every pixel is back in place.
|
||||||
# Like TubeSteer, only the coloured pixels go in. A black outline is drawn fresh
|
|
||||||
# round the stream in the tube, and round pixels still (or back) at their spot
|
|
||||||
# in the sprite. Pixels flying between the two don't get one: it would speckle
|
|
||||||
# them all in black.
|
|
||||||
|
|
||||||
# Where the slime's pixels draw while in a tube (this and TubeSteer and TubeGoo):
|
# Where the slime's pixels draw while in a tube (this and TubeSteer and TubeGoo):
|
||||||
# behind the tiles (z 0), which only show them through the tube's see-through
|
# behind the tiles (z 0), which only show them through the tube's see-through
|
||||||
|
|
@ -24,7 +20,6 @@ const SPEED = 240.0 # How fast pixels flow along the path, in px/s.
|
||||||
const ROW_SPACING = 1.0 # Gap between rows of pixels in the stream, unless that would make it too long.
|
const ROW_SPACING = 1.0 # Gap between rows of pixels in the stream, unless that would make it too long.
|
||||||
const GATHER_TIME = 0.12 # How long the nearest pixels take to reach the entry mouth.
|
const GATHER_TIME = 0.12 # How long the nearest pixels take to reach the entry mouth.
|
||||||
const LAND_TIME = 0.15 # How long the last pixels out take to reach their spot.
|
const LAND_TIME = 0.15 # How long the last pixels out take to reach their spot.
|
||||||
const SETTLED_DISTANCE = 1.0 # Pixels within this of their spot in the sprite get an outline.
|
|
||||||
|
|
||||||
var isFinished := false
|
var isFinished := false
|
||||||
|
|
||||||
|
|
@ -36,7 +31,6 @@ var _lanes := PackedFloat32Array() # How far left of the path's middle it flows.
|
||||||
var _rows := PackedInt32Array() # Its place in the stream: row 0 goes in first.
|
var _rows := PackedInt32Array() # Its place in the stream: row 0 goes in first.
|
||||||
var _rowCount := 0
|
var _rowCount := 0
|
||||||
var _rowSpacing := ROW_SPACING # Closer if needed to keep the stream within maxLength.
|
var _rowSpacing := ROW_SPACING # Closer if needed to keep the stream within maxLength.
|
||||||
var _footprint := {} # Vector2i -> true, for every spot in the sprite we took apart or put back.
|
|
||||||
|
|
||||||
var _path := PackedVector2Array()
|
var _path := PackedVector2Array()
|
||||||
var _pathDistances := PackedFloat32Array() # How far along the path each point is.
|
var _pathDistances := PackedFloat32Array() # How far along the path each point is.
|
||||||
|
|
@ -44,7 +38,7 @@ var _time := 0.0
|
||||||
|
|
||||||
|
|
||||||
# path: global points from the entry mouth to the exit mouth.
|
# path: global points from the entry mouth to the exit mouth.
|
||||||
# width: how wide the tube is. The stream is 2 pixels narrower, to leave room for its outline.
|
# width: how wide the tube is. The stream is this many pixels across.
|
||||||
# maxLength: the longest the stream can be. Rows bunch up (overlapping) to fit.
|
# maxLength: the longest the stream can be. Rows bunch up (overlapping) to fit.
|
||||||
# endTransform: the sprite's global transform once it's back together.
|
# endTransform: the sprite's global transform once it's back together.
|
||||||
# endFrame: the frame it reforms as, so it matches what the sprite shows next.
|
# endFrame: the frame it reforms as, so it matches what the sprite shows next.
|
||||||
|
|
@ -62,14 +56,12 @@ func start(sprite: Sprite2D, path: PackedVector2Array, width: float, maxLength:
|
||||||
# Where the sprite is drawn now: snapped to whole pixels like the renderer does.
|
# Where the sprite is drawn now: snapped to whole pixels like the renderer does.
|
||||||
var startTransform := sprite.get_global_transform()
|
var startTransform := sprite.get_global_transform()
|
||||||
startTransform.origin = startTransform.origin.round()
|
startTransform.origin = startTransform.origin.round()
|
||||||
var from := TubeSteer.without_outline(get_frame_pixels(sprite, sprite.frame, startTransform))
|
var from := get_frame_pixels(sprite, sprite.frame, startTransform)
|
||||||
var to := TubeSteer.without_outline(get_frame_pixels(sprite, endFrame, endTransform))
|
var to := get_frame_pixels(sprite, endFrame, endTransform)
|
||||||
if from.colors.is_empty() or to.colors.is_empty():
|
if from.colors.is_empty() or to.colors.is_empty():
|
||||||
isFinished = true
|
isFinished = true
|
||||||
return
|
return
|
||||||
_pair_pixels(from, to, maxi(int(width) - 2, 1))
|
_pair_pixels(from, to, maxi(int(width), 1))
|
||||||
for spot in from.positions + to.positions:
|
|
||||||
_footprint[Vector2i(spot.floor())] = true
|
|
||||||
_rowSpacing = minf(ROW_SPACING, maxLength / _rowCount)
|
_rowSpacing = minf(ROW_SPACING, maxLength / _rowCount)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -173,24 +165,16 @@ func _duration() -> float:
|
||||||
func _draw() -> void:
|
func _draw() -> void:
|
||||||
var tubeLength := _tube_length()
|
var tubeLength := _tube_length()
|
||||||
var duration := _duration()
|
var duration := _duration()
|
||||||
# Work out where every pixel goes first, so the outline can go round them.
|
|
||||||
var pixels := {} # Vector2i -> Color, for pixels in the tube or at their spot.
|
|
||||||
var movingPixels := {} # The same, for pixels on their way.
|
|
||||||
var inTube := {} # Vector2i -> true, for pixels in the tube.
|
|
||||||
for i in _starts.size():
|
for i in _starts.size():
|
||||||
var row := _rows[i]
|
var row := _rows[i]
|
||||||
var enterTime := _enter_time(row)
|
var enterTime := _enter_time(row)
|
||||||
var exitTime := _exit_time(row)
|
var exitTime := _exit_time(row)
|
||||||
var spot: Vector2
|
var spot: Vector2
|
||||||
var color := _startColors[i]
|
var color := _startColors[i]
|
||||||
var settled := false
|
|
||||||
if _time < enterTime:
|
if _time < enterTime:
|
||||||
# Drawn in, speeding up towards the mouth.
|
# Drawn in, speeding up towards the mouth.
|
||||||
var progress := _time / enterTime
|
var progress := _time / enterTime
|
||||||
spot = _starts[i].lerp(_point_on_path(0.0, _lanes[i]), progress * progress)
|
spot = _starts[i].lerp(_point_on_path(0.0, _lanes[i]), progress * progress)
|
||||||
if spot.distance_to(_starts[i]) <= SETTLED_DISTANCE:
|
|
||||||
settled = true
|
|
||||||
spot = _starts[i] # Held in place, so the sprite's shape stays crisp.
|
|
||||||
elif _time < exitTime:
|
elif _time < exitTime:
|
||||||
spot = _point_on_path((_time - enterTime) * SPEED, _lanes[i])
|
spot = _point_on_path((_time - enterTime) * SPEED, _lanes[i])
|
||||||
else:
|
else:
|
||||||
|
|
@ -199,34 +183,7 @@ func _draw() -> void:
|
||||||
var eased := 1.0 - (1.0 - progress) * (1.0 - progress)
|
var eased := 1.0 - (1.0 - progress) * (1.0 - progress)
|
||||||
spot = _point_on_path(tubeLength, _lanes[i]).lerp(_ends[i], eased)
|
spot = _point_on_path(tubeLength, _lanes[i]).lerp(_ends[i], eased)
|
||||||
color = _startColors[i].lerp(_endColors[i], eased)
|
color = _startColors[i].lerp(_endColors[i], eased)
|
||||||
if spot.distance_to(_ends[i]) <= SETTLED_DISTANCE:
|
draw_rect(Rect2(spot.floor(), Vector2.ONE), color)
|
||||||
settled = true
|
|
||||||
spot = _ends[i]
|
|
||||||
var at := Vector2i(spot.floor())
|
|
||||||
if _time >= enterTime and _time < exitTime:
|
|
||||||
pixels[at] = color
|
|
||||||
inTube[at] = true
|
|
||||||
elif settled:
|
|
||||||
pixels[at] = color
|
|
||||||
else:
|
|
||||||
movingPixels[at] = color
|
|
||||||
|
|
||||||
# The outline: every empty pixel touching the settled pixels. At their spot,
|
|
||||||
# corners count, like the slime's own outline. In the tube they don't, so
|
|
||||||
# the stream's outline hugs it. Spots inside the sprite's shape that pixels
|
|
||||||
# have left (or not reached yet) don't get one: they'd speckle it in black.
|
|
||||||
var outlined := {}
|
|
||||||
for at: Vector2i in pixels:
|
|
||||||
for offset in (TubeSteer.NEIGHBORS_4 if inTube.has(at) else TubeSteer.NEIGHBORS_8):
|
|
||||||
var spot: Vector2i = at + offset
|
|
||||||
if pixels.has(spot) or outlined.has(spot) or _footprint.has(spot):
|
|
||||||
continue
|
|
||||||
outlined[spot] = true
|
|
||||||
draw_rect(Rect2(Vector2(spot), Vector2.ONE), TubeSteer.OUTLINE_COLOR)
|
|
||||||
for at: Vector2i in pixels:
|
|
||||||
draw_rect(Rect2(Vector2(at), Vector2.ONE), pixels[at])
|
|
||||||
for at: Vector2i in movingPixels:
|
|
||||||
draw_rect(Rect2(Vector2(at), Vector2.ONE), movingPixels[at])
|
|
||||||
|
|
||||||
|
|
||||||
# The point `distance` along the path, moved `lane` to the left of travel.
|
# The point `distance` along the path, moved `lane` to the left of travel.
|
||||||
|
|
|
||||||
|
|
@ -148,8 +148,8 @@ func start(sprite: Sprite2D, layer: TileMapLayer, entryCell: Vector2i, entryDire
|
||||||
add_child(_indicatorCanvas)
|
add_child(_indicatorCanvas)
|
||||||
|
|
||||||
_laneCount = maxi(int(width) - 2, 1)
|
_laneCount = maxi(int(width) - 2, 1)
|
||||||
var from := without_outline(PixelStream.get_frame_pixels(sprite, sprite.frame, entryPose.get("startTransform", entryPose.spriteTransform)))
|
var from := _without_outline(PixelStream.get_frame_pixels(sprite, sprite.frame, entryPose.get("startTransform", entryPose.spriteTransform)))
|
||||||
_endFrame = without_outline(PixelStream.get_frame_pixels(sprite, endFrame, Transform2D.IDENTITY))
|
_endFrame = _without_outline(PixelStream.get_frame_pixels(sprite, endFrame, Transform2D.IDENTITY))
|
||||||
if from.colors.is_empty() or _endFrame.colors.is_empty():
|
if from.colors.is_empty() or _endFrame.colors.is_empty():
|
||||||
exitPose = entryPose
|
exitPose = entryPose
|
||||||
isFinished = true
|
isFinished = true
|
||||||
|
|
@ -241,8 +241,8 @@ func _process(delta: float) -> void:
|
||||||
|
|
||||||
# ---- Setup ----
|
# ---- Setup ----
|
||||||
|
|
||||||
# The frame's pixels without its dark outline and eyes. PixelStream uses this too.
|
# The frame's pixels without its dark outline and eyes.
|
||||||
static func without_outline(frame: Dictionary) -> Dictionary:
|
static func _without_outline(frame: Dictionary) -> Dictionary:
|
||||||
var positions := PackedVector2Array()
|
var positions := PackedVector2Array()
|
||||||
var colors := PackedColorArray()
|
var colors := PackedColorArray()
|
||||||
for i in frame.colors.size():
|
for i in frame.colors.size():
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,14 @@
|
||||||
[node name="TestLevel" type="Node2D" unique_id=1824208737]
|
[node name="TestLevel" type="Node2D" unique_id=1824208737]
|
||||||
|
|
||||||
[node name="Player" parent="." unique_id=150873177 instance=ExtResource("1_ormqy")]
|
[node name="Player" parent="." unique_id=150873177 instance=ExtResource("1_ormqy")]
|
||||||
position = Vector2(139, 307)
|
position = Vector2(329, 266)
|
||||||
|
|
||||||
[node name="TileMapLayer" type="TileMapLayer" parent="." unique_id=459516426]
|
[node name="TileMapLayer" type="TileMapLayer" par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ile_set = ExtResource("2_4k50d")
|
tile_set = ExtResource("2_4k50d")
|
||||||
|
|
||||||
[node name="CarryItem" parent="." unique_id=1653302373 instance=ExtResource("5_item")]
|
[node name="CarryItem" parent="." unique_id=1653302373 instance=ExtResource("5_item")]
|
||||||
position = Vector2(369, 44)
|
position = Vector2(380, 230)
|
||||||
|
|
||||||
[node name="PauseMenu" parent="." unique_id=904032161 instance=ExtResource("3_pause")]
|
[node name="PauseMenu" parent="." unique_id=904032161 instance=ExtResource("3_pause")]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
@ -25,5 +25,4 @@ visible = false
|
||||||
stream = ExtResource("4_i4ak4")
|
stream = ExtResource("4_i4ak4")
|
||||||
volume_db = -20.0
|
volume_db = -20.0
|
||||||
autoplay = true
|
autoplay = true
|
||||||
bus = &"Music"
|
|
||||||
parameters/looping = true
|
parameters/looping = true
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ config/icon="res://icon.svg"
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
PixelScreen="*res://Autoloads/pixel_screen.gd"
|
|
||||||
Settings="*res://Autoloads/settings.gd"
|
Settings="*res://Autoloads/settings.gd"
|
||||||
Transition="*res://Autoloads/transition.gd"
|
Transition="*res://Autoloads/transition.gd"
|
||||||
|
|
||||||
|
|
@ -28,6 +27,9 @@ window/size/viewport_height=480
|
||||||
window/size/mode=2
|
window/size/mode=2
|
||||||
window/size/window_width_override=1280
|
window/size/window_width_override=1280
|
||||||
window/size/window_height_override=960
|
window/size/window_height_override=960
|
||||||
|
window/stretch/mode="viewport"
|
||||||
|
window/stretch/aspect="expand"
|
||||||
|
window/stretch/scale_mode="integer"
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue