From 7779e241f66896f972f4a858ba9e7e19e6b68777 Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Thu, 6 Mar 2025 17:36:37 -0500 Subject: [PATCH] "splat-launch" move :3 --- assets/textures/player/capri.png | Bin 4664 -> 4840 bytes assets/textures/player/capri.xcf | Bin 5783 -> 7178 bytes maps/level_z.tscn | 12 ++++--- objects/ice/ice.gd | 4 +-- objects/player/player.gd | 34 ++++++++++++++++-- objects/player/player.tscn | 58 +++++++++++++++++++++++++++++-- 6 files changed, 97 insertions(+), 11 deletions(-) diff --git a/assets/textures/player/capri.png b/assets/textures/player/capri.png index c2ac482e1f1ff36efadb10c8d9e9b4cf49df7b0c..6ce2dc658348ccd8db8c7035247340ccc7f5e68e 100644 GIT binary patch delta 883 zcmV-(1C0E*BToGcl8v z1w{)vH8?pkG&eOhHZ+sw1&jzWHaamlIx#YndIly4F*Z6eI65&hlc)xZA~|McWi>H5 zEjcq{VJ$Q_IWa9_V=*}`H#Re5G-NSlV`es!RR>N8F*Z6eI65&hv#SSg2m~}EGhve* z5L|y15)AbFn1uiU0#HdrK~zY`jaA8#;~)$L;}2lzz6asC8>Rd1B+flG)%pKl8TQS| z%uuPwLJutTo&_P};NjN}Nv5^2Co+v|v^X_(5^@Ac(2b=4!z(E6hF7bW-3|b_Uv;%| z`5Cv6%k|fzSi0=+9CLsO2-f8=04Q4FUrv9~U`RrP9dfYbvN>xYTKM`noO0W|#blTH zO&R1@>zAR@gaQtx@yj^l+S@g9lZP-&^TraUmFDdsSAw=$H_)ObFGi;QeIU_(1ZF+t z^BsUGkZB)*RS%i=5tsv+_5-l$A=BOiOCZxe0;?V}?ISP;GVL#bSr59?M+TOF>OOyu z3M>Hz>!6QR2AOm)rBgE#+0Obj(Q)y zi^|@iJ=}PuofCQ@=2d%0?Ac=zl6zz|vZs$tsIVH?bAL(;-6x@vCOv!X47l98Ehy;1 zs$&nqK;ML1V5_t<0DXoLkm&WLM}&Vf5z@Zs4|w(!)l|6m&utT8iFZBu%;M6yX+lmg zB0N~e$)VE+{#m4eQ}Xx0|21#@$J67&o;E)@-O#D={ZvTa3v>$2izwOn&ZuyF--H9d z7%EbIilIPExbmkWFPFx57sFMae4PaB5rFqw;}f?0*38eF{bl8s8~L>CbR(i~vfcE6WU1mW)ZVv47y}iiSm;_NrdjA38K#(|SQr|o zr5dG9_GVRANwKsrGBr+3(oIe^wE!wKv(&Y)v`Eu6PBJn|G)Oc_HL^^bJdM?r+uXp? z(A?a_%*4`s@-x;RxC19wv8f?AE7-b~EK-4%7#iv(nI{?PnwY1i=q4taTIwbmnwyy= zS(>LLnoJI5_k-)%yqZ0agC%vru^E$P1!C&?L@obTwS8bw^YEqV$(-(n58H>|9D@4Wl}T9MX==?2SV9iBZ&xw2E?Lu|XD)TbX;7v3-k|9Ohd z>R8WpE&j!em{^ycl4;n}^!x0oNnf{EDm5IxJ7vwXe5=-3@7~8-e$H%`-^JF^q}*;Q z!1z7yPJR5jyjXA)nwz(>z)YQt32+ zVgl9bI&}_j)*6TlSc{6;E0k#+VM?+WTqN)Fm|x^sQ=VOaz0w(0M&pm}R%}yi43@-l zOJ^>&-y*9Nqj$OC=YqL^H}ZEH?=V^L@udBqfO*P$)88)qZv9h_YwtSSno~`&Ms=y* z*4V04t;=`H>JCx1y==bF=j#ITe_JGdcXQ0O*?C!*`^U?RJ_iq`tZJOc&YdgF)w(r7 zoFR=-%cJ7^;_q@|W?D|=m*oF!n!n;f6pc}_}&=7;xfviK5Yx-enJ#~lSuo7P>H j|KsYSU|D@s`(HgTe~DWM4fyt5ni diff --git a/assets/textures/player/capri.xcf b/assets/textures/player/capri.xcf index 35f1b36eb24a1434773e43502c14de7c85cc4520..1dd1ababa35d9c480a5aecf5db909cee1722aa75 100644 GIT binary patch delta 1431 zcmYLHJx^3o5S^KO-@dmW%EtmrAW;$vjlpO^p|P>D(Sn2?CA2157%g98LSifk&xFc| zKY=WT{sj{XV`*)q0|mmzE_*%a-CcIy-aB_@&Yd|kcQ)_5zrX%m|7@@9xChHp{wixx zW;;>VPNE#?ML9kj<-}5yQ=f~+{#LO(@v%7fi@LheoUtS?!swJGo5fc8r2RelqWX^Z zbgQ(dU)x*hsp>Xu)!ouo{oUTJUNJo^e${7Y8Y3}yxj(`_8uiA__DJKW*A8!vwQ#eg zciXM8J=N)r=BzH1v6@fY3(ebF+!+5*{F_+RC88%^7SASIy4HR>Ij55dHwc^HTv>Yc zV&!#leSDpo+$-kNhhuMe9R6CLNG)%D8=5X-z|{INus3~>d9RXUnK!vGfjm+1{P zBAFe53V_hT1JU)&)Olxy67BfX>8;`q=|MVA#vl}tie{MoEosIuY{Sr->4UW zGF9*fs0N-U(ZVX&(}WfHbA)5t6fXe~Th}eypht9gv~TFglb}_24mcE8kVB#DnC+v0 zob3Z`L}G#T@|B1`Uv_i+?eSLTy9Crd zCKJPkZ~@LP>U3bme#cqOfiTH@Q$m=>8Wjr(q{C`qC88mNtUx-s2!cIY8htMjJplmC z6<50ZrYck(G5#Tyv~=;DVMTZn@`_{t@NNPJK{YsOt3j_YwBgA60~6&yuSm7LGSCyL zBNVR=LQyAoAFAZvr%2r)%_^n?3GjYpe!Z-Lx*<67vmXgy8DO!*sHd=9g|7kogRPE#Qh)06l3BM-z?8_nT7E+ShXNKP_;Ot{AP8*7mSP?Krv}X m6|e!qHk)09wHPOtu}qo#OC*5N8?0V59V{tYzqwvife`>qP&PgQ diff --git a/maps/level_z.tscn b/maps/level_z.tscn index 7e4ad2c..ac7b628 100644 --- a/maps/level_z.tscn +++ b/maps/level_z.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=6 format=4 uid="uid://cccb8wltupasj"] +[gd_scene load_steps=7 format=4 uid="uid://cccb8wltupasj"] [ext_resource type="Texture2D" uid="uid://b6a7l24y30iht" path="res://assets/textures/backgrounds/chocomint.png" id="1_h5jcm"] [ext_resource type="Script" uid="uid://d3v13a4er2h1x" path="res://scripts/level/level.gd" id="1_hcs1r"] [ext_resource type="TileSet" uid="uid://xwfn24if3pxk" path="res://assets/tilesets/chocomint.tres" id="2_dj7w1"] [ext_resource type="PackedScene" uid="uid://c8r040r4glui4" path="res://objects/enemies/lashy/lashy.tscn" id="4_gykx6"] [ext_resource type="PackedScene" uid="uid://bwtpsjpe2lf7l" path="res://objects/player/player.tscn" id="5_5v7mr"] +[ext_resource type="PackedScene" uid="uid://68lav5rke5ag" path="res://objects/spring/spring.tscn" id="6_tlqas"] [node name="LevelZ" type="Node2D"] script = ExtResource("1_hcs1r") @@ -19,11 +20,14 @@ texture = ExtResource("1_h5jcm") [node name="TileMap" type="TileMapLayer" parent="."] use_parent_material = true -tile_map_data = PackedByteArray("AAAAAAsAAAAAAAAAAAABAAsAAAAAAAAAAAACAAsAAAAAAAAAAAAHAAsAAAAAAAAAAAAIAAsAAAAAAAAAAAAJAAsAAAAAAAAAAAAKAAsAAAAAAAAAAAALAAsAAAAAAAAAAAANAAsAAAAAAAAAAAAOAAsAAAAAAAAAAAAPAAsAAAAAAAAAAAAQAAsAAAAAAAAAAAARAAsAAAAAAAAAAAADAAsAAAAAAAAAAAAEAAsAAAAAAAAAAAAFAAsAAAAAAAAAAAAGAAsAAAAAAAAAAAAMAAsAAAAAAAAAAAAFAAoAAAAAAAAAAAAGAAoAAAAAAAAAAAAGAAkAAAAAAAAAAAAHAAkAAAAAAAAAAAAIAAkAAAAAAAAAAAAJAAkAAAAAAAAAAAAKAAkAAAAAAAAAAAALAAkAAAAAAAAAAAAMAAkAAAAAAAAAAAALAAoAAAAAAAAAAAAKAAoAAAAAAAAAAAAJAAoAAAAAAAAAAAAIAAoAAAAAAAAAAAAHAAoAAAAAAAAAAAAMAAoAAAAAAAAAAAANAAoAAAAAAAAAAAAOAAoAAAAAAAAAAAAPAAoAAAAAAAAAAAAPAAkAAAAAAAAAAAAQAAkAAAAAAAAAAAAQAAgAAAAAAAAAAAAQAAcAAAAAAAAAAAAQAAYAAAAAAAAAAAARAAcAAAAAAAAAAAAQAAoAAAAAAAAAAAARAAkAAAAAAAAAAAARAA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AAAAAAAAAARAAUAAAAAAAAAAAARAAQAAAAAAAAAAAAQAAQAAAAAAAAAAAAQAAUAAAAAAAAAAAAFAAkAAAAAAAAAAAAEAAkAAAAAAAAAAAADAAkAAAAAAAAAAAACAAkAAAAAAAAAAAABAAkAAAAAAAAAAAABAAoAAAAAAAAAAAACAAoAAAAAAAAAAAADAAoAAAAAAAAAAAAEAAoAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAkAAAAAAAAAAAAJAAgAAAAAAAAAAAAJAAcAAAAAAAAAAAAJAAYAAAAAAAAAAAAJAAUAAAAAAAAAAAAJAAQAAAAAAAAAAAAJAAMAAAAAAAAAAAAJAAIAAAAAAAAAAAABAAgAAAAAAAAAAAABAAcAAAAAAAAAAAABAAYAAAAAAAAAAAABAAUAAAAAAAAAAAABAAQAAAAAAAAAAAABAAMAAAAAAAAAAAABAAIAAAAAAAAAAAA=") tile_set = ExtResource("2_dj7w1") [node name="Lashy" parent="." instance=ExtResource("4_gykx6")] -position = Vector2(141, 99) +position = Vector2(264, 72) [node name="Player" parent="." instance=ExtResource("5_5v7mr")] -position = Vector2(40, 144) +position = Vector2(120, 144) + +[node name="Spring" parent="." instance=ExtResource("6_tlqas")] +position = Vector2(96, 144) diff --git a/objects/ice/ice.gd b/objects/ice/ice.gd index c061843..c0552f6 100644 --- a/objects/ice/ice.gd +++ b/objects/ice/ice.gd @@ -13,8 +13,8 @@ func _process(delta: float) -> void: func _on_area_2d_body_entered(body: Node2D) -> void: if body is Player: - body.ices_touched += 1 + pass func _on_area_2d_body_exited(body: Node2D) -> void: - body.ices_touched -= 1 + pass diff --git a/objects/player/player.gd b/objects/player/player.gd index edd2994..0e03485 100644 --- a/objects/player/player.gd +++ b/objects/player/player.gd @@ -11,6 +11,8 @@ extends CharacterBody2D @export_group("Air Movement") @export var gravity: float @export var jump_power: float +@export var splat_launch_power: float +@export var splat_offset: float @export_group("Internal References") @export var state_chart: StateChart @@ -26,8 +28,12 @@ var input_dir: Vector2 = Vector2.ZERO: input_dir = value.sign() state_chart.set_expression_property(&"input_dir", input_dir) +var _last_velocity: Vector2 = Vector2.ZERO +var _splat_normal: Vector2 = Vector2.ZERO + func _physics_process(delta: float) -> void: + _last_velocity = velocity move_and_slide() state_chart.set_expression_property(&"velocity", velocity) if velocity.x != 0.0: @@ -88,11 +94,35 @@ func _start_jump() -> void: #region Missile +func _restore_graphics_rotation() -> void: + graphics.rotation = 0.0 + + func _face_towards_velocity(_delta: float) -> void: graphics.rotation = Vector2(graphics.scale.x, 0.0).angle_to(velocity) -func _restore_graphics_rotation() -> void: - graphics.rotation = 0.0 +func _check_for_splat(delta: float) -> void: + var col = move_and_collide(_last_velocity * delta, true) + if col: + velocity = Vector2.ZERO + global_position += col.get_travel() + _splat_normal = col.get_normal() + var angle = col.get_normal().angle() + if graphics.scale.x > 0.0: + angle += PI + graphics.set_deferred(&"rotation", angle) + state_chart.send_event(&"splatted") +#endregion + + +#region Splatting +func _do_splat_launch() -> void: + var dir = input_dir.project(_splat_normal.orthogonal()).normalized() + if dir == Vector2.ZERO: + dir = _splat_normal + dir = dir.rotated(dir.angle_to(_splat_normal) * 0.5) + + launch(dir * splat_launch_power) #endregion diff --git a/objects/player/player.tscn b/objects/player/player.tscn index c08bdcd..71e1bad 100644 --- a/objects/player/player.tscn +++ b/objects/player/player.tscn @@ -79,23 +79,24 @@ turn_acceleration = 300.0 stopping_force = 200.0 gravity = 450.0 jump_power = 180.0 +splat_launch_power = 240.0 +splat_offset = 6.0 state_chart = NodePath("StateChart") graphics = NodePath("Graphics") run_animation = NodePath("Graphics/Sprite/Run") [node name="CollisionShape" type="CollisionShape2D" parent="."] -position = Vector2(0, -6) shape = SubResource("CircleShape2D_tvyy1") debug_color = Color(3.32102e-06, 0.648976, 0.161954, 0.42) [node name="Graphics" type="Node2D" parent="."] -position = Vector2(0, -6) [node name="Sprite" type="Sprite2D" parent="Graphics"] texture = ExtResource("3_trcll") offset = Vector2(0, -2) hframes = 4 vframes = 4 +frame = 10 region_rect = Rect2(0, 0, 64, 64) [node name="Idle" type="Node" parent="Graphics/Sprite"] @@ -128,6 +129,18 @@ first_frame = Vector2i(1, 2) script = ExtResource("4_bsdw5") first_frame = Vector2i(2, 2) +[node name="Splat" type="Node" parent="Graphics/Sprite"] +script = ExtResource("4_bsdw5") +first_frame = Vector2i(0, 3) +frames = 2 +fps = 8.0 + +[node name="UnSplat" type="Node" parent="Graphics/Sprite"] +script = ExtResource("4_bsdw5") +first_frame = Vector2i(2, 3) +frames = 2 +fps = 8.0 + [node name="Sounds" type="Node" parent="."] [node name="Voice" type="AudioStreamPlayer" parent="Sounds"] @@ -140,7 +153,6 @@ bus = &"Capri" [node name="StateChart" type="Node" parent="."] script = ExtResource("5_bcjtl") -track_in_editor = true initial_expression_properties = { &"input_dir": Vector2(0, 0), &"on_floor": false, @@ -285,6 +297,41 @@ delay_in_seconds = "0.0" editor_description = "Player is hurtling through the air and ricocheting off of surfaces." script = ExtResource("10_mvu25") +[node name="on Splatted" type="Node" parent="StateChart/Root/Airborne/Missile"] +editor_description = "Transition to splat state when the player hits a wall" +script = ExtResource("7_rgjdc") +to = NodePath("../../../Floating/Splat") +event = &"splatted" +delay_in_seconds = "0.0" + +[node name="Floating" type="Node" parent="StateChart/Root"] +script = ExtResource("6_jnxnd") +initial_state = NodePath("UnSplat") + +[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") + +[node name="on JumpPressed" type="Node" parent="StateChart/Root/Floating/Splat"] +script = ExtResource("7_rgjdc") +to = NodePath("..") +event = &"jump_pressed" +delay_in_seconds = "" + +[node name="on TimeOut" type="Node" parent="StateChart/Root/Floating/Splat"] +script = ExtResource("7_rgjdc") +to = NodePath("../../UnSplat") +delay_in_seconds = "0.75" + +[node name="UnSplat" type="Node" parent="StateChart/Root/Floating"] +editor_description = "Player is unsticking from a surface." +script = ExtResource("10_mvu25") + +[node name="on TimeOut" type="Node" parent="StateChart/Root/Floating/UnSplat"] +script = ExtResource("7_rgjdc") +to = NodePath("../../../Airborne/Falling") +delay_in_seconds = ".25" + [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"] @@ -304,3 +351,8 @@ script = ExtResource("10_mvu25") [connection signal="state_entered" from="StateChart/Root/Airborne/Missile" to="Graphics/Sprite/Missile" method="play"] [connection signal="state_exited" from="StateChart/Root/Airborne/Missile" to="." method="_restore_graphics_rotation"] [connection signal="state_physics_processing" from="StateChart/Root/Airborne/Missile" to="." method="_face_towards_velocity"] +[connection signal="state_physics_processing" from="StateChart/Root/Airborne/Missile" to="." method="_check_for_splat"] +[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"] +[connection signal="state_exited" from="StateChart/Root/Floating/UnSplat" to="." method="_restore_graphics_rotation"]