diff --git a/assets/audio/sfx/spark_bounce.ogg b/assets/audio/sfx/spark_bounce.ogg new file mode 100644 index 0000000..4810a23 Binary files /dev/null and b/assets/audio/sfx/spark_bounce.ogg differ diff --git a/assets/audio/sfx/spark_bounce.ogg.import b/assets/audio/sfx/spark_bounce.ogg.import new file mode 100644 index 0000000..ef15a05 --- /dev/null +++ b/assets/audio/sfx/spark_bounce.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://cmvbwm6gk8n6b" +path="res://.godot/imported/spark_bounce.ogg-224666db975db87c427084fd6483ed17.oggvorbisstr" + +[deps] + +source_file="res://assets/audio/sfx/spark_bounce.ogg" +dest_files=["res://.godot/imported/spark_bounce.ogg-224666db975db87c427084fd6483ed17.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/assets/textures/effects/spark.png b/assets/textures/effects/spark.png new file mode 100644 index 0000000..ab73f11 Binary files /dev/null and b/assets/textures/effects/spark.png differ diff --git a/assets/textures/effects/spark.png.import b/assets/textures/effects/spark.png.import new file mode 100644 index 0000000..4c2eadd --- /dev/null +++ b/assets/textures/effects/spark.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://rhc3c5j1lfw" +path="res://.godot/imported/spark.png-81510591edeaafcb46d1dae5039251df.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/effects/spark.png" +dest_files=["res://.godot/imported/spark.png-81510591edeaafcb46d1dae5039251df.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/autoloads/scene_manager.tscn b/autoloads/scene_manager.tscn index 4e9a340..18ede0a 100644 --- a/autoloads/scene_manager.tscn +++ b/autoloads/scene_manager.tscn @@ -45,5 +45,6 @@ pivot_offset = Vector2(144, 108) [node name="SubViewport" type="SubViewport" parent="ViewportHolder/ViewportContainer"] handle_input_locally = false canvas_item_default_texture_filter = 0 +audio_listener_enable_2d = true size = Vector2i(288, 216) render_target_update_mode = 4 diff --git a/maps/level_z.tscn b/maps/level_z.tscn index 2d295e5..defe54d 100644 --- a/maps/level_z.tscn +++ b/maps/level_z.tscn @@ -24,11 +24,11 @@ texture = ExtResource("1_h5jcm") [node name="TileMap" type="TileMapLayer" parent="."] z_index = -100 use_parent_material = true -tile_map_data = PackedByteArray("AAAAAAsAAAAAAAAAAAABAAsAAAAAAAAAAAACAAsAAAAAAAAAAAAHAAsAAAAAAAAAAAAIAAsAAAAAAAAAAAAJAAsAAAAAAAAAAAAKAAsAAAAAAAAAAAALAAsAAAAAAAAAAAANAAsAAAAAAAAAAAAOAAsAAAAAAAAAAAAPAAsAAAAAAAAAAAAQAAsAAAAAAAAAAAARAAsAAAAAAAAAAAADAAsAAAAAAAAAAAAEAAsAAAAAAAAAAAAFAAsAAAAAAAAAAAAGAAsAAAAAAAAAAAAMAAsAAAAAAAAAAAAFAAoAAAAAAAAAAAAGAAoAAAAAAAAAAAAGAAkAAAAAAAAAAAAHAAkAAAAAAAAAAAAIAAkAAAAAAAAAAAAJAAkAAAAAAAAAAAAKAAkAAAAAAAAAAAALAAkAAAAAAAAAAAAMAAkAAAAAAAAAAAALAAoAAAAAAAAAAAAKAAoAAAAAAAAAAAAJAAoAAAAAAAAAAAAIAAoAAAAAAAAAAAAHAAoAAAAAAAAAAAAMAAoAAAAAAAAAAAANAAoAAAAAAAAAAAAOAAoAAAAAAAAAAAAPAAoAAAAAAAAAAAAPAAkAAAAAAAAAAAAQAAkAAAAAAAAAAAAQAAoAAAAAAAAAAAARAAkAAAAAAAAA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AAkAAAAAAAAAAAARAAoAAAAAAAAAAAAFAAkAAAAAAAAAAAAEAAkAAAAAAAAAAAADAAkAAAAAAAAAAAACAAkAAAAAAAAAAAABAAkAAAAAAAAAAAABAAoAAAAAAAAAAAACAAoAAAAAAAAAAAADAAoAAAAAAAAAAAAEAAoAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAkAAAAAAAAAAAABAAgAAAAAAAAAAAABAAcAAAAAAAAAAAABAAYAAAAAAAAAAAABAAUAAAAAAAAAAAABAAQAAAAAAAAAAAABAAMAAAAAAAAAAAABAAIAAAAAAAAAAAANAAkAAAAAAAAAAAAOAAkAAAAAAAAAAAAFAAYAAAAAAAAAAAAFAAUAAAAAAAAAAAAFAAQAAAAAAAAAAAAFAAMAAAAAAAAAAAAFAAIAAAAAAAAAAAAFAAEAAAAAAAAAAAABAAEAAAAAAAAAAAABAAAAAAAAAAAAAAABAP//AAAAAAAAAAABAP7/AAAAAAAAAAABAP3/AAAAAAAAAAACAP3/AAAAAAAAAAADAP3/AAAAAAAAAAAEAP3/AAAAAAAAAAAFAP3/AAAAAAAAAAAGAP3/AAAAAAAAAAAHAP3/AAAAAAAAAAAIAP3/AAAAAAAAAAAJAP3/AAAAAAAAAAAKAAgAAAAAAAAAAAAKAAcAAAAAAAAAAAALAAcAAAAAAAAAAAALAAgAAAAAAAAAAAAMAAYAAAAAAAAAAAAMAAUAAAAAAAAAAAAMAAQAAAAAAAAAAAANAAQAAAAAAAAAAAANAAUAAAAAAAAAAAANAAYAAAAAAAAAAAANAAcAAAAAAAAAAAANAAgAAAAAAAAAAAAMAAgAAAAAAAAAAAAMAAcAAAAAAAAAAAAOAAQAAAAAAAAAAAAOAAUAAAAAAAAAAAAOAAYAAAAAAAAAAAAOAAcAAAAAAAAAAAAOAAgAAAAAAAAAAAA=") tile_set = ExtResource("2_dj7w1") [node name="Lashy" parent="." instance=ExtResource("4_gykx6")] -position = Vector2(88, 40) +position = Vector2(272, 104) launch_power = 300.0 idle_radius = 6.0 @@ -36,7 +36,7 @@ idle_radius = 6.0 position = Vector2(96, 136) [node name="Spring" parent="." instance=ExtResource("6_tlqas")] -position = Vector2(32, 72) +position = Vector2(256, 144) [node name="RotoBoy" parent="." instance=ExtResource("7_j1102")] position = Vector2(240, 40) diff --git a/objects/effects/bouncing_spark.gd b/objects/effects/bouncing_spark.gd new file mode 100644 index 0000000..e66c818 --- /dev/null +++ b/objects/effects/bouncing_spark.gd @@ -0,0 +1,35 @@ +extends RigidBody2D + + +@export var scale_min: float +@export var scale_max: float +@export var velocity_min: float +@export var velocity_max: float +@export_custom(0, "radians_as_degrees") var spin_min: float +@export_custom(0, "radians_as_degrees") var spin_max: float +@export var decay_speed_threshold: float +@export var decay_time: float + + +var _tween: Tween = null + + +func _ready() -> void: + var rnd_scale = randf_range(scale_min, scale_max) + $Sprite2D.scale = Vector2.ONE * rnd_scale + + linear_velocity = Vector2.from_angle(randf() * TAU) * randf_range(velocity_min, velocity_max) + angular_velocity = randf_range(spin_min, spin_max) + + +func _physics_process(delta: float) -> void: + if linear_velocity.length() <= decay_speed_threshold: + if _tween: + return + _tween = create_tween().set_process_mode(Tween.TWEEN_PROCESS_PHYSICS) + _tween.tween_property(self, ^"scale", Vector2.ZERO, decay_time) + _tween.tween_callback(queue_free) + + +func _on_solid_detector_body_entered(body: Node2D) -> void: + print("BLEP") diff --git a/objects/effects/bouncing_spark.gd.uid b/objects/effects/bouncing_spark.gd.uid new file mode 100644 index 0000000..48a2682 --- /dev/null +++ b/objects/effects/bouncing_spark.gd.uid @@ -0,0 +1 @@ +uid://b6krgij5xfu1w diff --git a/objects/effects/bouncing_spark.tscn b/objects/effects/bouncing_spark.tscn new file mode 100644 index 0000000..8eeb0ec --- /dev/null +++ b/objects/effects/bouncing_spark.tscn @@ -0,0 +1,57 @@ +[gd_scene load_steps=8 format=3 uid="uid://djdpcsmms727b"] + +[ext_resource type="Script" uid="uid://b6krgij5xfu1w" path="res://objects/effects/bouncing_spark.gd" id="1_62ynp"] +[ext_resource type="Texture2D" uid="uid://rhc3c5j1lfw" path="res://assets/textures/effects/spark.png" id="1_ag5ij"] +[ext_resource type="AudioStream" uid="uid://cmvbwm6gk8n6b" path="res://assets/audio/sfx/spark_bounce.ogg" id="3_4uvf2"] + +[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_62ynp"] +bounce = 0.8 + +[sub_resource type="CircleShape2D" id="CircleShape2D_4uvf2"] +radius = 2.0 + +[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_us66k"] +random_pitch = 1.25 +streams_count = 1 +stream_0/stream = ExtResource("3_4uvf2") + +[sub_resource type="CircleShape2D" id="CircleShape2D_us66k"] +radius = 6.0 + +[node name="Spark" type="RigidBody2D"] +z_index = -10 +collision_layer = 0 +collision_mask = 3 +mass = 0.1 +physics_material_override = SubResource("PhysicsMaterial_62ynp") +gravity_scale = 0.25 +linear_damp = 0.3 +script = ExtResource("1_62ynp") +scale_min = 0.5 +scale_max = 1.0 +velocity_min = 40.0 +velocity_max = 80.0 +spin_min = -1.5708 +spin_max = 1.5708 +decay_speed_threshold = 15.0 +decay_time = 0.2 + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("1_ag5ij") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_4uvf2") + +[node name="BounceSound" type="AudioStreamPlayer2D" parent="."] +stream = SubResource("AudioStreamRandomizer_us66k") +bus = &"Sound Effects" + +[node name="SolidDetector" type="Area2D" parent="."] +collision_layer = 0 +collision_mask = 3 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="SolidDetector"] +shape = SubResource("CircleShape2D_us66k") + +[connection signal="body_entered" from="SolidDetector" to="." method="_on_solid_detector_body_entered"] +[connection signal="body_entered" from="SolidDetector" to="BounceSound" method="play" unbinds=1] diff --git a/objects/player/player.gd b/objects/player/player.gd index 20dcd43..8bf6459 100644 --- a/objects/player/player.gd +++ b/objects/player/player.gd @@ -7,8 +7,12 @@ extends CharacterBody2D @export var max_run_speed: float @export var turn_acceleration: float @export var stopping_force: float + +@export_group("Bonk") @export var bonk_speed_threshold: float @export var bonk_power: float +@export var bonk_effect_count: int +@export var bonk_effect_scene: PackedScene @export_group("Air Movement") @export var gravity: float @@ -30,6 +34,8 @@ extends CharacterBody2D @export var corner_snap_point: Node2D @export var vault_off_point: Node2D +@export var bonk_effect_point: Node2D + @onready var start_position: Vector2 = global_position @@ -113,6 +119,10 @@ func _cancel_bonk() -> void: func _apply_bonk() -> void: velocity.x = signf(_bonk_cancel_velocity.x) * bonk_power + for _i in bonk_effect_count: + var effect_instance = bonk_effect_scene.instantiate() + effect_instance.global_position = global_position + get_parent().add_child(effect_instance) #endregion diff --git a/objects/player/player.tscn b/objects/player/player.tscn index 7bd3388..f78ad35 100644 --- a/objects/player/player.tscn +++ b/objects/player/player.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=36 format=3 uid="uid://bwtpsjpe2lf7l"] +[gd_scene load_steps=37 format=3 uid="uid://bwtpsjpe2lf7l"] [ext_resource type="Script" uid="uid://dhyi4yn0xleoy" path="res://objects/player/player.gd" id="1_xs4s5"] +[ext_resource type="PackedScene" uid="uid://djdpcsmms727b" path="res://objects/effects/bouncing_spark.tscn" id="2_28utn"] [ext_resource type="Texture2D" uid="uid://c71nqfyw4a3v4" path="res://assets/textures/player/capri.png" id="3_trcll"] [ext_resource type="Script" uid="uid://cv55s54clajw5" path="res://scripts/spritesheet_animation/spritesheet_animation.gd" id="4_bsdw5"] [ext_resource type="AudioStream" uid="uid://4kxio0mlrr4k" path="res://assets/audio/vox/capri_jump2.ogg" id="5_45urx"] @@ -108,7 +109,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", "wall_cast", "corner_cast", "corner_height_cast", "corner_snap_point", "vault_off_point")] +[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", "bonk_effect_point")] collision_layer = 16 collision_mask = 3 floor_snap_length = 3.0 @@ -119,6 +120,8 @@ turn_acceleration = 300.0 stopping_force = 250.0 bonk_speed_threshold = 75.0 bonk_power = 80.0 +bonk_effect_count = 3 +bonk_effect_scene = ExtResource("2_28utn") gravity = 450.0 fast_gravity = 675.0 jump_power = 180.0 @@ -134,6 +137,7 @@ 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") +bonk_effect_point = NodePath("Graphics/SparksPoint") [node name="CollisionShape" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_tvyy1") @@ -232,6 +236,9 @@ position = Vector2(4, 2) [node name="VaultOffPoint" type="Node2D" parent="Graphics/CornerDetector"] position = Vector2(2, 7) +[node name="SparksPoint" type="Node2D" parent="Graphics"] +position = Vector2(8, 0) + [node name="Sounds" type="Node" parent="."] [node name="Jump" type="AudioStreamPlayer" parent="Sounds"] @@ -517,16 +524,16 @@ delay_in_seconds = "0.0" [connection signal="state_physics_processing" from="StateChart/Root/Grounded" to="." method="_check_for_bonk"] [connection signal="state_entered" from="StateChart/Root/Grounded/Standing/Idle" to="Graphics/Sprite/Idle" method="play"] [connection signal="state_entered" from="StateChart/Root/Grounded/Standing/Stopping" to="Graphics/Sprite/Run" method="play"] -[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_physics_processing" from="StateChart/Root/Grounded/Standing/Stopping" to="." method="_slow_to_stop"] [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="_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_physics_processing" from="StateChart/Root/Airborne" to="." method="_check_for_bonk"] +[connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_check_for_corner"] +[connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_apply_gravity"] [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="Graphics/Sprite/Jump" method="play"] [connection signal="state_entered" from="StateChart/Root/Airborne/Jumping/FromGround" to="." method="_start_jump"]