Add some extra sprites for pressing up or down while attached to both floor and ceiling.

This commit is contained in:
SnekInAScarf 2026-11-16 22:19:33 -08:00
parent bb3dc29f48
commit e916c5611b
3 changed files with 102 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -82,6 +82,10 @@ const PRESS_WALL_SPRITE_SHIFT = 6.0
# surfaces (see _align_press_wall_sprite). # surfaces (see _align_press_wall_sprite).
const BRIDGE_FRAME = 10 # Wall to wall. Drawn upright, so it's turned a quarter. 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_VERTICAL_FRAME = 11 # Floor to ceiling.
# Floor to ceiling, leaning towards the surface we're holding towards: most of
# us down on the floor, or up on the ceiling.
const BRIDGE_VERTICAL_DOWN_FRAME = 12
const BRIDGE_VERTICAL_UP_FRAME = 13
const BRIDGE_GAP = 32.0 # One tile. const BRIDGE_GAP = 32.0 # One tile.
const BRIDGE_GAP_TOLERANCE = 1.5 const BRIDGE_GAP_TOLERANCE = 1.5
const IN_AIR_FRAME = 8 # The InAir animation's frame. const IN_AIR_FRAME = 8 # The InAir animation's frame.
@ -154,6 +158,9 @@ var bridgeAxis := Vector2.RIGHT # RIGHT between walls, DOWN between floor and ce
var bridgeHoldSide := 0.0 # Which way along bridgeAxis we're holding (1, -1), or 0. var bridgeHoldSide := 0.0 # Which way along bridgeAxis we're holding (1, -1), or 0.
var timeSpentLeavingBridge := 0.0 var timeSpentLeavingBridge := 0.0
var timeSpentDroppingFromBridge := 0.0 var timeSpentDroppingFromBridge := 0.0
# Between floor and ceiling, which one we're holding towards: -1 up, 1 down, or 0.
# Read by the AnimationTree to lean the column that way.
var bridgeLean := 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.
@ -206,7 +213,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 in [BRIDGE_FRAME, BRIDGE_VERTICAL_FRAME, BRIDGE_VERTICAL_DOWN_FRAME, BRIDGE_VERTICAL_UP_FRAME]:
# The sprite's offset lifts it off the surface we're on. Undo that so the # The sprite's offset lifts it off the surface we're on. Undo that so the
# column sits centred on us, between the surfaces. # column sits centred on us, between the surfaces.
targetPosition -= sprite.offset.rotated(sprite.rotation).round() targetPosition -= sprite.offset.rotated(sprite.rotation).round()
@ -636,6 +643,7 @@ func _begin_bridge(normal: Vector2, ownPoint: Vector2, otherPoint: Vector2) -> v
# We're still holding away from the surface we left, towards the one across. # 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. # Keep holding and we cross over to it after HOLD_TIME, like any other hold.
bridgeHoldSide = signf(normal.dot(bridgeAxis)) bridgeHoldSide = signf(normal.dot(bridgeAxis))
_update_bridge_lean()
velocity = Vector2.ZERO velocity = Vector2.ZERO
# Halfway between the surfaces, staying put the other way. # Halfway between the surfaces, staying put the other way.
@ -650,6 +658,11 @@ func _begin_bridge(normal: Vector2, ownPoint: Vector2, otherPoint: Vector2) -> v
_show_pose(&"Bridge", BRIDGE_FRAME) _show_pose(&"Bridge", BRIDGE_FRAME)
else: else:
_set_sprite_rotation(0.0) _set_sprite_rotation(0.0)
if bridgeLean < 0:
_show_pose(&"BridgeVerticalUp", BRIDGE_VERTICAL_UP_FRAME)
elif bridgeLean > 0:
_show_pose(&"BridgeVerticalDown", BRIDGE_VERTICAL_DOWN_FRAME)
else:
_show_pose(&"BridgeVertical", BRIDGE_VERTICAL_FRAME) _show_pose(&"BridgeVertical", BRIDGE_VERTICAL_FRAME)
@ -669,6 +682,7 @@ func _update_bridge(delta: float, moveInput: Vector2) -> void:
else: else:
timeSpentLeavingBridge = 0.0 timeSpentLeavingBridge = 0.0
bridgeHoldSide = side bridgeHoldSide = side
_update_bridge_lean()
# Between walls only down drops us (bridgeAxis.orthogonal() is up there). # Between walls only down drops us (bridgeAxis.orthogonal() is up there).
var holdingToDrop := along == 0.0 and across != 0.0 var holdingToDrop := along == 0.0 and across != 0.0
@ -685,6 +699,12 @@ func _update_bridge(delta: float, moveInput: Vector2) -> void:
_drop_from_bridge() _drop_from_bridge()
# Leans the floor-to-ceiling column towards the surface we're holding towards
# (bridgeAxis is DOWN there, so the hold side is already -1 up, 1 down).
func _update_bridge_lean() -> void:
bridgeLean = int(bridgeHoldSide) if bridgeAxis == Vector2.DOWN else 0
# Lets go of both surfaces and falls from where we are. # Lets go of both surfaces and falls from where we are.
func _drop_from_bridge() -> void: func _drop_from_bridge() -> void:
isBridging = false isBridging = false

View file

@ -46,6 +46,40 @@ tracks/0/keys = {
"values": [11] "values": [11]
} }
[sub_resource type="Animation" id="Animation_BridgeVerticalDown"]
resource_name = "BridgeVerticalDown"
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": [12]
}
[sub_resource type="Animation" id="Animation_BridgeVerticalUp"]
resource_name = "BridgeVerticalUp"
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": [13]
}
[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
@ -182,6 +216,8 @@ tracks/0/keys = {
_data = { _data = {
&"Bridge": SubResource("Animation_Bridge"), &"Bridge": SubResource("Animation_Bridge"),
&"BridgeVertical": SubResource("Animation_BridgeVertical"), &"BridgeVertical": SubResource("Animation_BridgeVertical"),
&"BridgeVerticalDown": SubResource("Animation_BridgeVerticalDown"),
&"BridgeVerticalUp": SubResource("Animation_BridgeVerticalUp"),
&"Crouch": SubResource("Animation_Crouch"), &"Crouch": SubResource("Animation_Crouch"),
&"Idle": SubResource("Animation_Idle"), &"Idle": SubResource("Animation_Idle"),
&"InAir": SubResource("Animation_InAir"), &"InAir": SubResource("Animation_InAir"),
@ -198,6 +234,12 @@ animation = &"Bridge"
[sub_resource type="AnimationNodeAnimation" id="AnimNode_BridgeVertical"] [sub_resource type="AnimationNodeAnimation" id="AnimNode_BridgeVertical"]
animation = &"BridgeVertical" animation = &"BridgeVertical"
[sub_resource type="AnimationNodeAnimation" id="AnimNode_BridgeVerticalDown"]
animation = &"BridgeVerticalDown"
[sub_resource type="AnimationNodeAnimation" id="AnimNode_BridgeVerticalUp"]
animation = &"BridgeVerticalUp"
[sub_resource type="AnimationNodeAnimation" id="AnimNode_Crouch"] [sub_resource type="AnimationNodeAnimation" id="AnimNode_Crouch"]
animation = &"Crouch" animation = &"Crouch"
@ -398,9 +440,45 @@ advance_expression = "not isBridging"
advance_mode = 2 advance_mode = 2
advance_expression = "not isBridging" advance_expression = "not isBridging"
[sub_resource type="AnimationNodeStateMachineTransition" id="Transition_BridgeVertical_BridgeVerticalUp"]
advance_mode = 2
advance_expression = "isBridging and bridgeLean < 0"
[sub_resource type="AnimationNodeStateMachineTransition" id="Transition_BridgeVertical_BridgeVerticalDown"]
advance_mode = 2
advance_expression = "isBridging and bridgeLean > 0"
[sub_resource type="AnimationNodeStateMachineTransition" id="Transition_BridgeVerticalUp_BridgeVertical"]
advance_mode = 2
advance_expression = "isBridging and bridgeLean == 0"
[sub_resource type="AnimationNodeStateMachineTransition" id="Transition_BridgeVerticalUp_BridgeVerticalDown"]
advance_mode = 2
advance_expression = "isBridging and bridgeLean > 0"
[sub_resource type="AnimationNodeStateMachineTransition" id="Transition_BridgeVerticalUp_Idle"]
advance_mode = 2
advance_expression = "not isBridging"
[sub_resource type="AnimationNodeStateMachineTransition" id="Transition_BridgeVerticalDown_BridgeVertical"]
advance_mode = 2
advance_expression = "isBridging and bridgeLean == 0"
[sub_resource type="AnimationNodeStateMachineTransition" id="Transition_BridgeVerticalDown_BridgeVerticalUp"]
advance_mode = 2
advance_expression = "isBridging and bridgeLean < 0"
[sub_resource type="AnimationNodeStateMachineTransition" id="Transition_BridgeVerticalDown_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/node = SubResource("AnimNode_BridgeVertical")
states/BridgeVertical/position = Vector2(1150, 300) states/BridgeVertical/position = Vector2(1150, 300)
states/BridgeVerticalDown/node = SubResource("AnimNode_BridgeVerticalDown")
states/BridgeVerticalDown/position = Vector2(1400, 400)
states/BridgeVerticalUp/node = SubResource("AnimNode_BridgeVerticalUp")
states/BridgeVerticalUp/position = Vector2(1400, 200)
states/Bridge/node = SubResource("AnimNode_Bridge") states/Bridge/node = SubResource("AnimNode_Bridge")
states/Bridge/position = Vector2(900, 300) states/Bridge/position = Vector2(900, 300)
states/Crouch/node = SubResource("AnimNode_Crouch") states/Crouch/node = SubResource("AnimNode_Crouch")
@ -418,7 +496,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"), "Bridge", "Idle", SubResource("Transition_Bridge_Idle"), "BridgeVertical", "Idle", SubResource("Transition_BridgeVertical_Idle"), "BridgeVertical", "BridgeVerticalUp", SubResource("Transition_BridgeVertical_BridgeVerticalUp"), "BridgeVertical", "BridgeVerticalDown", SubResource("Transition_BridgeVertical_BridgeVerticalDown"), "BridgeVerticalUp", "BridgeVertical", SubResource("Transition_BridgeVerticalUp_BridgeVertical"), "BridgeVerticalUp", "BridgeVerticalDown", SubResource("Transition_BridgeVerticalUp_BridgeVerticalDown"), "BridgeVerticalUp", "Idle", SubResource("Transition_BridgeVerticalUp_Idle"), "BridgeVerticalDown", "BridgeVertical", SubResource("Transition_BridgeVerticalDown_BridgeVertical"), "BridgeVerticalDown", "BridgeVerticalUp", SubResource("Transition_BridgeVerticalDown_BridgeVerticalUp"), "BridgeVerticalDown", "Idle", SubResource("Transition_BridgeVerticalDown_Idle")]
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 +506,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 = 14
[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")