Add FootstepGfx and JumpGfxComponent; implement particle effects for footsteps and jumps
This commit is contained in:
@@ -6,7 +6,7 @@ namespace Mr.BrickAdventures.Autoloads;
|
||||
public partial class SpeedRunManager : Node
|
||||
{
|
||||
public bool IsRunning { get; private set; } = false;
|
||||
public bool IsVisible { get; private set; } = true;
|
||||
public bool IsVisible { get; private set; } = false;
|
||||
|
||||
private double _startTime;
|
||||
private double _levelStartTime;
|
||||
|
31
objects/entities/bouncing_mushroom.tscn
Normal file
31
objects/entities/bouncing_mushroom.tscn
Normal file
@@ -0,0 +1,31 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://c0j1yun5s7kns"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bu0yv6rktj221" path="res://sprites/bouncing_mushroom.png" id="1_t1exj"]
|
||||
[ext_resource type="Script" uid="uid://bgbnof7aeydmq" path="res://scripts/components/JumpPadComponent.cs" id="2_w2gbr"]
|
||||
[ext_resource type="PackedScene" uid="uid://qo2ngbnkix85" path="res://objects/fxs/bounce_gfx.tscn" id="3_w2gbr"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ci3ij"]
|
||||
size = Vector2(22, 10)
|
||||
|
||||
[node name="Bouncing Mushrrom" type="Area2D"]
|
||||
modulate = Color(1.1, 1.1, 1.1, 1)
|
||||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, -13)
|
||||
shape = SubResource("RectangleShape2D_ci3ij")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(0, -8)
|
||||
texture = ExtResource("1_t1exj")
|
||||
hframes = 2
|
||||
|
||||
[node name="JumpPadComponent" type="Node" parent="." node_paths=PackedStringArray("Area", "Sprite", "Particles")]
|
||||
script = ExtResource("2_w2gbr")
|
||||
JumpForce = 600.0
|
||||
Area = NodePath("..")
|
||||
Sprite = NodePath("../Sprite2D")
|
||||
Particles = NodePath("../BounceGFX")
|
||||
|
||||
[node name="BounceGFX" parent="." instance=ExtResource("3_w2gbr")]
|
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=54 format=3 uid="uid://bqi5s710xb1ju"]
|
||||
[gd_scene load_steps=58 format=3 uid="uid://bqi5s710xb1ju"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://csel4s0e4g5uf" path="res://scripts/components/PlayerController.cs" id="1_yysbb"]
|
||||
[ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="2_lgb3u"]
|
||||
@@ -42,6 +42,10 @@
|
||||
[ext_resource type="Script" uid="uid://c00siqtssccr6" path="res://scripts/components/PacXonGridInteractor.cs" id="42_xuhvf"]
|
||||
[ext_resource type="Script" uid="uid://ceoxet1nqws8w" path="res://scripts/components/SpriteTilterComponent.cs" id="43_xuhvf"]
|
||||
[ext_resource type="Script" uid="uid://cmk4m7mplqnrm" path="res://scripts/components/PacXonTrailComponent.cs" id="44_uno3u"]
|
||||
[ext_resource type="PackedScene" uid="uid://de5emerpbiknb" path="res://objects/fxs/foot_step_gfx.tscn" id="45_bl1gx"]
|
||||
[ext_resource type="Script" uid="uid://d3ksrjt1ek4gi" path="res://scripts/components/FootstepGfx.cs" id="46_6n1ss"]
|
||||
[ext_resource type="Script" uid="uid://bpopfy6m4a0br" path="res://scripts/components/JumpGfxComponent.cs" id="47_oefns"]
|
||||
[ext_resource type="PackedScene" uid="uid://bqhondao5bm6k" path="res://objects/fxs/jump_cloud_fx.tscn" id="48_bnap0"]
|
||||
[ext_resource type="Script" uid="uid://b1h8r5irryxcx" path="res://scripts/components/PlayerSfxComponent.cs" id="49_qec3q"]
|
||||
[ext_resource type="Script" uid="uid://b2aanqykvdnev" path="res://scripts/components/PlayerGraphicsComponent.cs" id="50_dhjci"]
|
||||
|
||||
@@ -308,3 +312,23 @@ metadata/_custom_type_script = "uid://c00siqtssccr6"
|
||||
[node name="PacXonTrailComponent" type="Line2D" parent="."]
|
||||
script = ExtResource("44_uno3u")
|
||||
metadata/_custom_type_script = "uid://cmk4m7mplqnrm"
|
||||
|
||||
[node name="Feet" type="Marker2D" parent="."]
|
||||
position = Vector2(0, 16)
|
||||
|
||||
[node name="FootstepGfx" type="Node2D" parent="." node_paths=PackedStringArray("_controller", "_marker")]
|
||||
script = ExtResource("46_6n1ss")
|
||||
_particles = ExtResource("45_bl1gx")
|
||||
_controller = NodePath("..")
|
||||
_marker = NodePath("../Feet")
|
||||
_stepInterval = 0.4
|
||||
_stepIntervalRandomness = 0.15
|
||||
_minMoveSpeed = 4.0
|
||||
_randomOffsetRange = 0.3
|
||||
metadata/_custom_type_script = "uid://d3ksrjt1ek4gi"
|
||||
|
||||
[node name="JumpGfxComponent" type="Node2D" parent="." node_paths=PackedStringArray("Controller")]
|
||||
script = ExtResource("47_oefns")
|
||||
ParticleScene = ExtResource("48_bnap0")
|
||||
Controller = NodePath("..")
|
||||
metadata/_custom_type_script = "uid://bpopfy6m4a0br"
|
||||
|
39
objects/fxs/bounce_gfx.tscn
Normal file
39
objects/fxs/bounce_gfx.tscn
Normal file
@@ -0,0 +1,39 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://qo2ngbnkix85"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_qxp43"]
|
||||
offsets = PackedFloat32Array(0, 0.289256, 0.790634)
|
||||
colors = PackedColorArray(0.635294, 1, 0.952941, 1, 0.380392, 0.827451, 0.890196, 1, 0.188235, 0.317647, 0.509804, 1)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_1jx8o"]
|
||||
gradient = SubResource("Gradient_qxp43")
|
||||
use_hdr = true
|
||||
|
||||
[sub_resource type="Curve" id="Curve_8fwqm"]
|
||||
_data = [Vector2(0.251928, 1), 0.0, -3.43942, 0, 0, Vector2(1, 0.340954), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_365fl"]
|
||||
curve = SubResource("Curve_8fwqm")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_wfuta"]
|
||||
particle_flag_disable_z = true
|
||||
emission_shape = 3
|
||||
emission_box_extents = Vector3(10, 1, 1)
|
||||
angle_min = -45.0
|
||||
angle_max = 45.0
|
||||
direction = Vector3(0, 1, 0)
|
||||
spread = 15.0
|
||||
initial_velocity_min = 5.0
|
||||
initial_velocity_max = 10.0
|
||||
gravity = Vector3(0, 98, 0)
|
||||
scale_curve = SubResource("CurveTexture_365fl")
|
||||
color_ramp = SubResource("GradientTexture1D_1jx8o")
|
||||
|
||||
[node name="BounceGFX" type="GPUParticles2D"]
|
||||
emitting = false
|
||||
amount = 52
|
||||
one_shot = true
|
||||
explosiveness = 1.0
|
||||
fixed_fps = 24
|
||||
collision_base_size = 3.32
|
||||
process_material = SubResource("ParticleProcessMaterial_wfuta")
|
52
objects/fxs/foot_step_gfx.tscn
Normal file
52
objects/fxs/foot_step_gfx.tscn
Normal file
@@ -0,0 +1,52 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://de5emerpbiknb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://v7tt4w6bejux" path="res://scripts/components/CleanupComponent.cs" id="1_lnlfk"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_lnlfk"]
|
||||
_data = [Vector2(0.00771208, 1), 0.0, 0.0, 0, 0, Vector2(0.347044, 0.89662), -1.20644, -1.20644, 0, 0, Vector2(1, 0.0114315), 0.0, 0.0, 0, 0]
|
||||
point_count = 3
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_a3r26"]
|
||||
curve = SubResource("Curve_lnlfk")
|
||||
|
||||
[sub_resource type="Curve" id="Curve_et0te"]
|
||||
_data = [Vector2(0, 1), 0.0, -2.46687, 0, 0, Vector2(0.192802, 0.6834), 0.0, 0.0, 0, 0, Vector2(0.449871, 1), -0.471266, -0.471266, 0, 0, Vector2(1, 0), -3.06444, 0.0, 0, 0]
|
||||
point_count = 4
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_lnlfk"]
|
||||
width = 2048
|
||||
curve = SubResource("Curve_et0te")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_a3r26"]
|
||||
particle_flag_disable_z = true
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 1.0
|
||||
direction = Vector3(0, -1, 0)
|
||||
spread = 0.93
|
||||
flatness = 1.0
|
||||
initial_velocity_min = 11.0
|
||||
initial_velocity_max = 11.0
|
||||
angular_velocity_min = -80.0
|
||||
angular_velocity_max = -80.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
scale_min = 1.25
|
||||
scale_max = 1.75
|
||||
scale_curve = SubResource("CurveTexture_lnlfk")
|
||||
color = Color(0.47451, 0.47451, 0.47451, 1)
|
||||
alpha_curve = SubResource("CurveTexture_a3r26")
|
||||
|
||||
[node name="FootStepGfx" type="GPUParticles2D"]
|
||||
emitting = false
|
||||
amount = 42
|
||||
lifetime = 2.0
|
||||
one_shot = true
|
||||
speed_scale = 2.0
|
||||
explosiveness = 1.0
|
||||
fixed_fps = 24
|
||||
process_material = SubResource("ParticleProcessMaterial_a3r26")
|
||||
|
||||
[node name="CleanupComponent" type="Node" parent="."]
|
||||
script = ExtResource("1_lnlfk")
|
||||
metadata/_custom_type_script = "uid://v7tt4w6bejux"
|
||||
|
||||
[connection signal="finished" from="." to="CleanupComponent" method="CleanUp"]
|
52
objects/fxs/jump_cloud_fx.tscn
Normal file
52
objects/fxs/jump_cloud_fx.tscn
Normal file
@@ -0,0 +1,52 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bqhondao5bm6k"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://v7tt4w6bejux" path="res://scripts/components/CleanupComponent.cs" id="1_0051n"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_0051n"]
|
||||
_data = [Vector2(0.00771208, 1), 0.0, 0.0, 0, 0, Vector2(0.347044, 0.89662), -1.20644, -1.20644, 0, 0, Vector2(1, 0.0114315), 0.0, 0.0, 0, 0]
|
||||
point_count = 3
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_oxugj"]
|
||||
curve = SubResource("Curve_0051n")
|
||||
|
||||
[sub_resource type="Curve" id="Curve_cc2b5"]
|
||||
_data = [Vector2(0, 1), 0.0, -2.46687, 0, 0, Vector2(0.192802, 0.6834), 0.0, 0.0, 0, 0, Vector2(0.449871, 1), -0.471266, -0.471266, 0, 0, Vector2(1, 0), -3.06444, 0.0, 0, 0]
|
||||
point_count = 4
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_qdic5"]
|
||||
width = 2048
|
||||
curve = SubResource("Curve_cc2b5")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_vwfwg"]
|
||||
particle_flag_disable_z = true
|
||||
emission_shape = 1
|
||||
emission_sphere_radius = 2.25
|
||||
angle_min = 23.1
|
||||
angle_max = 107.8
|
||||
direction = Vector3(0, 1, 0)
|
||||
spread = 4.0
|
||||
initial_velocity_min = 8.0
|
||||
initial_velocity_max = 8.0
|
||||
angular_velocity_min = -80.0
|
||||
angular_velocity_max = -80.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
scale_min = 3.0
|
||||
scale_max = 4.0
|
||||
scale_curve = SubResource("CurveTexture_qdic5")
|
||||
alpha_curve = SubResource("CurveTexture_oxugj")
|
||||
|
||||
[node name="FootStepGfx" type="GPUParticles2D"]
|
||||
emitting = false
|
||||
amount = 64
|
||||
lifetime = 2.0
|
||||
one_shot = true
|
||||
speed_scale = 4.0
|
||||
explosiveness = 1.0
|
||||
fixed_fps = 24
|
||||
process_material = SubResource("ParticleProcessMaterial_vwfwg")
|
||||
|
||||
[node name="CleanupComponent" type="Node" parent="."]
|
||||
script = ExtResource("1_0051n")
|
||||
metadata/_custom_type_script = "uid://v7tt4w6bejux"
|
||||
|
||||
[connection signal="finished" from="." to="CleanupComponent" method="CleanUp"]
|
@@ -1,4 +1,4 @@
|
||||
[gd_resource type="TileSet" load_steps=15 format=3 uid="uid://bc5a20s6kuy8e"]
|
||||
[gd_resource type="TileSet" load_steps=16 format=3 uid="uid://bc5a20s6kuy8e"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://djifxc5x0dyrw" path="res://sprites/ppc_tileset.png" id="1_ej5iv"]
|
||||
[ext_resource type="PackedScene" uid="uid://54w4wisfj8v8" path="res://objects/entities/coin.tscn" id="2_31a0q"]
|
||||
@@ -6,6 +6,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://ct8fim6mduyl3" path="res://objects/entities/collapsing_bridge.tscn" id="3_x63lh"]
|
||||
[ext_resource type="PackedScene" uid="uid://bargnp4twtmxg" path="res://objects/entities/big_coin.tscn" id="4_ov0dn"]
|
||||
[ext_resource type="PackedScene" uid="uid://buff711j0f2ph" path="res://objects/entities/spike_wheel.tscn" id="4_x63lh"]
|
||||
[ext_resource type="PackedScene" uid="uid://c0j1yun5s7kns" path="res://objects/entities/bouncing_mushroom.tscn" id="5_ov0dn"]
|
||||
[ext_resource type="PackedScene" uid="uid://d08dfqmirnd66" path="res://objects/entities/big_treasure.tscn" id="5_xxibl"]
|
||||
[ext_resource type="PackedScene" uid="uid://073ts5cxtwbl" path="res://objects/entities/treasure.tscn" id="6_fmgww"]
|
||||
[ext_resource type="PackedScene" uid="uid://cm3rixnnev1pg" path="res://objects/entities/jump_pad.tscn" id="7_0kjxj"]
|
||||
@@ -149,6 +150,7 @@ scenes/8/scene = ExtResource("9_at40q")
|
||||
scenes/9/scene = ExtResource("10_ivcjr")
|
||||
scenes/10/scene = ExtResource("3_31a0q")
|
||||
scenes/11/scene = ExtResource("4_x63lh")
|
||||
scenes/12/scene = ExtResource("5_ov0dn")
|
||||
|
||||
[resource]
|
||||
physics_layer_0/collision_layer = 1
|
||||
|
157
scenes/level_village_5.tscn
Normal file
157
scenes/level_village_5.tscn
Normal file
File diff suppressed because one or more lines are too long
55
scripts/components/FootstepGfx.cs
Normal file
55
scripts/components/FootstepGfx.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class FootstepGfx : Node2D
|
||||
{
|
||||
[Export] private PackedScene _particles;
|
||||
[Export] private PlayerController _controller;
|
||||
[Export] private Marker2D _marker;
|
||||
|
||||
[ExportGroup("Footstep Settings")]
|
||||
[Export] private double _stepInterval = 0.5; // Time in seconds between steps
|
||||
[Export] private double _stepIntervalRandomness = 0.1; // Randomness factor for step interval
|
||||
[Export] private double _minMoveSpeed = 10.0; // Minimum speed to trigger footsteps
|
||||
[Export] private double _randomOffsetRange = 5.0; // Range for random offset
|
||||
|
||||
private double _timeSinceLastStep = 0.0;
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
if (_controller == null || _particles == null) return;
|
||||
|
||||
var canMakeFootstep = _controller.IsOnFloor() && _controller.Velocity.Length() >= _minMoveSpeed;
|
||||
|
||||
if (canMakeFootstep)
|
||||
{
|
||||
_timeSinceLastStep += delta;
|
||||
var randomFactor = GD.RandRange(-_stepIntervalRandomness, _stepIntervalRandomness);
|
||||
var adjustedStepInterval = _stepInterval + randomFactor;
|
||||
if (_timeSinceLastStep >= adjustedStepInterval)
|
||||
{
|
||||
SpawnFootstep();
|
||||
_timeSinceLastStep = 0.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_timeSinceLastStep = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnFootstep()
|
||||
{
|
||||
if (_marker == null) return;
|
||||
var randomOffset = new Vector2(
|
||||
(float)GD.RandRange(-_randomOffsetRange, _randomOffsetRange),
|
||||
(float)GD.RandRange(-_randomOffsetRange, _randomOffsetRange)
|
||||
);
|
||||
var newParticles = _particles.Instantiate<GpuParticles2D>();
|
||||
newParticles.GlobalPosition = _marker.GlobalPosition + randomOffset;
|
||||
GetTree().CurrentScene.AddChild(newParticles);
|
||||
newParticles.Emitting = true;
|
||||
}
|
||||
}
|
1
scripts/components/FootstepGfx.cs.uid
Normal file
1
scripts/components/FootstepGfx.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d3ksrjt1ek4gi
|
35
scripts/components/JumpGfxComponent.cs
Normal file
35
scripts/components/JumpGfxComponent.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class JumpGfxComponent : Node2D
|
||||
{
|
||||
[Export] public PackedScene ParticleScene { get; set; }
|
||||
[Export] public PlayerController Controller { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (Controller == null)
|
||||
{
|
||||
GD.PrintErr("JumpGfxComponent must have a reference to a PlayerController.");
|
||||
SetProcess(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Controller.JumpInitiated += OnJumpInitiated;
|
||||
}
|
||||
|
||||
private void OnJumpInitiated()
|
||||
{
|
||||
SpawnGfx();
|
||||
}
|
||||
|
||||
private void SpawnGfx()
|
||||
{
|
||||
var particleInstance = ParticleScene.Instantiate<GpuParticles2D>();
|
||||
particleInstance.GlobalPosition = GlobalPosition;
|
||||
GetTree().CurrentScene.AddChild(particleInstance);
|
||||
particleInstance.Emitting = true;
|
||||
}
|
||||
}
|
1
scripts/components/JumpGfxComponent.cs.uid
Normal file
1
scripts/components/JumpGfxComponent.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bpopfy6m4a0br
|
@@ -11,6 +11,7 @@ public partial class JumpPadComponent : Node
|
||||
[Export] public Sprite2D Sprite { get; set; }
|
||||
[Export] public int StartAnimationIndex { get; set; } = 0;
|
||||
[Export] public float AnimationDuration { get; set; } = 0.5f;
|
||||
[Export] public GpuParticles2D Particles { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -27,6 +28,7 @@ public partial class JumpPadComponent : Node
|
||||
_ = HandleLaunchPadAnimation();
|
||||
player.Velocity = new Vector2(player.Velocity.X, -JumpForce);
|
||||
player.EmitSignal(PlayerController.SignalName.JumpInitiated);
|
||||
Particles?.Restart();
|
||||
}
|
||||
|
||||
private async Task HandleLaunchPadAnimation()
|
||||
|
BIN
sprites/bouncing_mushroom.png
Normal file
BIN
sprites/bouncing_mushroom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 479 B |
34
sprites/bouncing_mushroom.png.import
Normal file
34
sprites/bouncing_mushroom.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bu0yv6rktj221"
|
||||
path="res://.godot/imported/bouncing_mushroom.png-60ba3b31dc13cf870987497004bff09d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sprites/bouncing_mushroom.png"
|
||||
dest_files=["res://.godot/imported/bouncing_mushroom.png-60ba3b31dc13cf870987497004bff09d.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
|
Reference in New Issue
Block a user