From 5cf87d8bb7e9146f653b75fc50a46360fba994e1 Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Sat, 15 Mar 2025 04:39:38 -0400 Subject: [PATCH] chomp vault to help getting up corners --- assets/textures/player/capri.png | Bin 4840 -> 5044 bytes assets/textures/player/capri.xcf | Bin 7178 -> 8435 bytes maps/level_z.tscn | 4 +- objects/player/player.gd | 31 +++++++++++ objects/player/player.tscn | 93 ++++++++++++++++++++++++++++--- 5 files changed, 118 insertions(+), 10 deletions(-) diff --git a/assets/textures/player/capri.png b/assets/textures/player/capri.png index 6ce2dc658348ccd8db8c7035247340ccc7f5e68e..390564ca3c1658ded69f1973d631a37184cc5048 100644 GIT binary patch delta 1591 zcmZ8hSyU4T6rB*VfChq4L6kij+Y+2i7G@$MOClnhV9=BX$|L~=TY(7D9>F96M+K!~ z6t$%kjTkT*id0rni&i!TmA2Zl1OYcf1Bg)%Tbh3O8|`+VSC$%bGlmJ8@CoxFoXBCuSr!^c?S~ zqwD18_5C)Jg9PGz=e~c-DHSV=PerINz+rQJc)t)GvD-dN%0C}R#YxO+p7GN zfp^M`FxEUiv+~8&c8gwzE5d!n z0!nFD{N;Ugjes-lkRj|NbveHF-(A)K>#uQk>y$UaIA-bT#>m~4Dc*^85T&Y0Rp`8m zvdedKZAs+}UoLwx(>)f`8H@93_hVNCPtOm_ruNI~_oYbNq6#m{ha4X-IN>~70yIyX zb?w@I4yLX5)~ScnX-vi0s7EVZXa_9s)GLbg#TN~j)9Y_NP*w{HsRb!kmCL3MY|`-o ze41i0R<`Hgy=DFY@iQ5J)t48u{)j1mzdGLu257^E@9h=_)QW)LN@=@5es`m$k( zvJ@9g`u|3JAp}NzS!_`G9CyTq&f%Ul`V2WEAqlN&})wi77{J>+Ir) z>mBF0PwsoYQIs_+J~UGH{Wn@L*uI;cXgmtH+HkZG~PNS>XYo%7n;oM7DXEHTb>DHN67>u^{3 zKi8_T!;7_d6*A@O9_#9SPs91x*tGWogc4B^2 zZAn^mhN+Afme?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YH)WUQ7PI;!m!X_pf_ z1?}yO#A$Ho3m7Ag9SRS4MzPxgC-9>p5V4B^#uPb63WRZnGB+fwiyDQ(kYdy&fFeqR zjW-&RDOR+C?|BW|i|06GG_{`q(~uarL0PzJDm0viNZl4WJSYx<2Bl>5Bmk*<>X`^I z-m1`6Mms<W=p}(a3q1;X8G?iJALRft1My=3!8aLx5Rtu+|D~ors((bWn))*Q wiKcFpKX+fnty|NZAAk7##cF$`cOY%nt6W+s#WGs#cxWU^&62D6?qxw0D?S{UjZ8i4pBkwK}&`8lN}nfZB2b_fZ{$qmdi zEaQMC0s&h)gyz@+p}D?8X#Rf?T1Xl~iv&YxvH6oDSu`de6ib=>kIi5*FKYl}^5jGo z;mP|s*_l}DK}=SlO4jL`xsTb7WtR?t@kx>FJCu{ void: #endregion +#region ChompVault +func _check_for_corner(_delta: float) -> void: + if signf(input_dir.x) == signf(graphics.scale.x): + corner_cast.force_raycast_update() + if not corner_cast.is_colliding(): + wall_cast.force_shapecast_update() + if wall_cast.is_colliding(): + state_chart.send_event(&"corner_detected") + +func _start_chomp_vault() -> void: + corner_height_cast.force_raycast_update() + global_position.x = wall_cast.get_collision_point(0).x + global_position.y = corner_height_cast.get_collision_point().y + global_position -= to_local(corner_snap_point.global_position) + velocity = Vector2.ZERO + +func _end_chomp_vault() -> void: + global_position += to_local(corner_snap_point.global_position) + global_position -= to_local(vault_off_point.global_position) + velocity = chomp_vault_impulse + velocity.x *= signf(graphics.scale.x) +#endregion + + #region Missile func _restore_graphics_rotation() -> void: graphics.rotation = 0.0 diff --git a/objects/player/player.tscn b/objects/player/player.tscn index cc7aa23..cfe8fc9 100644 --- a/objects/player/player.tscn +++ b/objects/player/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=35 format=3 uid="uid://bwtpsjpe2lf7l"] +[gd_scene load_steps=36 format=3 uid="uid://bwtpsjpe2lf7l"] [ext_resource type="Script" uid="uid://dhyi4yn0xleoy" path="res://objects/player/player.gd" id="1_xs4s5"] [ext_resource type="Texture2D" uid="uid://c71nqfyw4a3v4" path="res://assets/textures/player/capri.png" id="3_trcll"] @@ -23,6 +23,9 @@ [sub_resource type="CircleShape2D" id="CircleShape2D_tvyy1"] radius = 6.0 +[sub_resource type="RectangleShape2D" id="RectangleShape2D_l55sg"] +size = Vector2(4, 5) + [sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_45rsp"] streams_count = 3 stream_0/stream = ExtResource("9_8c74o") @@ -105,7 +108,7 @@ script = ExtResource("8_8i2im") expression = "velocity.y > 0.0" metadata/_custom_type_script = "uid://b6u7unac5srh0" -[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("state_chart", "graphics", "run_animation")] +[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("state_chart", "graphics", "run_animation", "wall_cast", "corner_cast", "corner_height_cast", "corner_snap_point", "vault_off_point")] collision_layer = 16 collision_mask = 3 floor_snap_length = 3.0 @@ -118,9 +121,15 @@ gravity = 450.0 jump_power = 180.0 splat_launch_power = 240.0 splat_offset = 6.0 +chomp_vault_impulse = Vector2(60, -60) state_chart = NodePath("StateChart") graphics = NodePath("Graphics") run_animation = NodePath("Graphics/Sprite/Run") +wall_cast = NodePath("Graphics/CornerDetector/WallCast") +corner_cast = NodePath("Graphics/CornerDetector/CornerCast") +corner_height_cast = NodePath("Graphics/CornerDetector/CornerHeightCast") +corner_snap_point = NodePath("Graphics/CornerDetector/CornerSnapPoint") +vault_off_point = NodePath("Graphics/CornerDetector/VaultOffPoint") [node name="CollisionShape" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_tvyy1") @@ -131,9 +140,9 @@ debug_color = Color(3.32102e-06, 0.648976, 0.161954, 0.42) [node name="Sprite" type="Sprite2D" parent="Graphics"] texture = ExtResource("3_trcll") offset = Vector2(0, -2) -hframes = 4 +hframes = 8 vframes = 4 -frame = 10 +frame = 7 region_rect = Rect2(0, 0, 64, 64) [node name="Idle" type="Node" parent="Graphics/Sprite"] @@ -178,6 +187,40 @@ first_frame = Vector2i(2, 3) frames = 2 fps = 8.0 +[node name="ChompVault" type="Node" parent="Graphics/Sprite"] +editor_description = "Triggers transition out of ChompVault state when animation is finished." +script = ExtResource("4_bsdw5") +first_frame = Vector2i(4, 0) +frames = 3 +fps = 10.0 +metadata/_custom_type_script = "uid://cv55s54clajw5" + +[node name="CornerDetector" type="Node2D" parent="Graphics"] +metadata/_edit_group_ = true + +[node name="WallCast" type="ShapeCast2D" parent="Graphics/CornerDetector"] +position = Vector2(0, 2.5) +enabled = false +shape = SubResource("RectangleShape2D_l55sg") +target_position = Vector2(6, 0) +max_results = 1 + +[node name="CornerCast" type="RayCast2D" parent="Graphics/CornerDetector"] +position = Vector2(0, -1) +enabled = false +target_position = Vector2(8, 0) + +[node name="CornerHeightCast" type="RayCast2D" parent="Graphics/CornerDetector"] +position = Vector2(9, -1) +enabled = false +target_position = Vector2(0, 8) + +[node name="CornerSnapPoint" type="Node2D" parent="Graphics/CornerDetector"] +position = Vector2(4, 2) + +[node name="VaultOffPoint" type="Node2D" parent="Graphics/CornerDetector"] +position = Vector2(2, 7) + [node name="Sounds" type="Node" parent="."] [node name="Jump" type="AudioStreamPlayer" parent="Sounds"] @@ -330,9 +373,16 @@ delay_in_seconds = "0.0" editor_description = "Player is falling down." script = ExtResource("10_mvu25") +[node name="on CornerDetected" type="Node" parent="StateChart/Root/Airborne/Falling"] +script = ExtResource("7_rgjdc") +to = NodePath("../../../Floating/ChompVault") +event = &"corner_detected" +delay_in_seconds = "0.0" + [node name="Jumping" type="Node" parent="StateChart/Root/Airborne"] editor_description = "Player has jumped and is rising." -script = ExtResource("10_mvu25") +script = ExtResource("6_jnxnd") +initial_state = NodePath("FromGround") [node name="if DownVelocity" type="Node" parent="StateChart/Root/Airborne/Jumping"] editor_description = "Transition to the falling state if moving downwards." @@ -341,6 +391,18 @@ to = NodePath("../../Falling") guard = SubResource("Resource_whx0j") delay_in_seconds = "0.0" +[node name="on CornerDetected" type="Node" parent="StateChart/Root/Airborne/Jumping"] +script = ExtResource("7_rgjdc") +to = NodePath("../../../Floating/ChompVault") +event = &"corner_detected" +delay_in_seconds = "0.0" + +[node name="FromGround" type="Node" parent="StateChart/Root/Airborne/Jumping"] +script = ExtResource("10_mvu25") + +[node name="NoBoost" type="Node" parent="StateChart/Root/Airborne/Jumping"] +script = ExtResource("10_mvu25") + [node name="Missile" type="Node" parent="StateChart/Root/Airborne"] editor_description = "Player is hurtling through the air and ricocheting off of surfaces." script = ExtResource("10_mvu25") @@ -356,6 +418,16 @@ delay_in_seconds = "0.0" script = ExtResource("6_jnxnd") initial_state = NodePath("UnSplat") +[node name="ChompVault" type="Node" parent="StateChart/Root/Floating"] +editor_description = "Player is launching off of a corner." +script = ExtResource("10_mvu25") + +[node name="on AnimationFinished" type="Node" parent="StateChart/Root/Floating/ChompVault"] +script = ExtResource("7_rgjdc") +to = NodePath("../../../Airborne/Jumping/NoBoost") +event = &"*animation_finished" +delay_in_seconds = "0.0" + [node name="Splat" type="Node" parent="StateChart/Root/Floating"] editor_description = "Player has slammed into a surface (and has a moment to perform an action?)" script = ExtResource("10_mvu25") @@ -380,6 +452,7 @@ script = ExtResource("7_rgjdc") to = NodePath("../../../Airborne/Falling") delay_in_seconds = "0.25" +[connection signal="finished" from="Graphics/Sprite/ChompVault" to="StateChart/Root/Floating/ChompVault/on AnimationFinished" method="take"] [connection signal="taken" from="StateChart/Root/on Killed" to="." method="_reset_position"] [connection signal="taken" from="StateChart/Root/on Killed" to="Sounds/Death" method="play"] [connection signal="state_entered" from="StateChart/Root/Grounded/Standing/Idle" to="Graphics/Sprite/Idle" method="play"] @@ -387,15 +460,16 @@ delay_in_seconds = "0.25" [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Standing/Stopping" to="." method="_slow_to_stop"] [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Standing/Stopping" to="." method="_scale_run_animation"] [connection signal="state_entered" from="StateChart/Root/Grounded/Running" to="Graphics/Sprite/Run" method="play"] -[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_apply_run_acceleration"] [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_scale_run_animation"] +[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_apply_run_acceleration"] [connection signal="state_entered" from="StateChart/Root/Grounded/Turning" to="Graphics/Sprite/Skid" method="play"] [connection signal="state_physics_processing" from="StateChart/Root/Grounded/Turning" to="." method="_apply_turn_acceleration"] [connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_apply_gravity"] +[connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_check_for_corner"] [connection signal="state_entered" from="StateChart/Root/Airborne/Falling" to="Graphics/Sprite/Fall" method="play"] -[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="." method="_start_jump"] [connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="Graphics/Sprite/Jump" method="play"] -[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="Sounds/Jump" method="play"] +[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping/FromGround" to="." method="_start_jump"] +[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping/FromGround" to="Sounds/Jump" method="play"] [connection signal="state_entered" from="StateChart/Root/Airborne/Missile" to="Graphics/Sprite/Missile" method="play"] [connection signal="state_entered" from="StateChart/Root/Airborne/Missile" to="Sounds/Whee" method="play"] [connection signal="state_entered" from="StateChart/Root/Airborne/Missile" to="Sounds/Wallkick" method="play"] @@ -403,6 +477,9 @@ delay_in_seconds = "0.25" [connection signal="state_physics_processing" from="StateChart/Root/Airborne/Missile" to="." method="_check_for_splat"] [connection signal="state_physics_processing" from="StateChart/Root/Airborne/Missile" to="." method="_face_towards_velocity"] [connection signal="taken" from="StateChart/Root/Airborne/Missile/on Splatted" to="Sounds/HitWall" method="play"] +[connection signal="state_entered" from="StateChart/Root/Floating/ChompVault" to="." method="_start_chomp_vault"] +[connection signal="state_entered" from="StateChart/Root/Floating/ChompVault" to="Graphics/Sprite/ChompVault" method="play"] +[connection signal="taken" from="StateChart/Root/Floating/ChompVault/on AnimationFinished" to="." method="_end_chomp_vault"] [connection signal="state_entered" from="StateChart/Root/Floating/Splat" to="Graphics/Sprite/Splat" method="play"] [connection signal="taken" from="StateChart/Root/Floating/Splat/on JumpPressed" to="." method="_do_splat_launch"] [connection signal="state_entered" from="StateChart/Root/Floating/UnSplat" to="Graphics/Sprite/UnSplat" method="play"]