generated from krampus/template-godot4
Extracted ball collection particle lagic into HUDParticle type
This commit is contained in:
parent
5c3da56226
commit
a65d08599f
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dtsdecae83ah3"
|
||||
path="res://.godot/imported/ball.png-9141da4d584001e11280d9c246b59589.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/particles/ball.png"
|
||||
dest_files=["res://.godot/imported/ball.png-9141da4d584001e11280d9c246b59589.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=true
|
||||
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
|
|
@ -13,4 +13,4 @@ func _collect(player: WorldPlayer) -> void:
|
|||
player.mutate_balls(ball_type, amount)
|
||||
|
||||
player.shot_setup.hud.peek_club_selector()
|
||||
player.shot_setup.hud.emit_ball_particles(maxi(amount, 1), screen_location())
|
||||
player.shot_setup.hud.ball_particles.emit_spatial(maxi(amount, 1), global_position)
|
||||
|
|
|
@ -10,14 +10,6 @@ signal on_collect(player: WorldPlayer)
|
|||
@onready var explosion_player: AnimationPlayer = %ExplosionPlayer
|
||||
|
||||
|
||||
## Relative location of this item in screen coordinates.
|
||||
## Useful for particle effects
|
||||
func screen_location() -> Vector2:
|
||||
var location := get_viewport().get_camera_3d().unproject_position(global_position)
|
||||
# TODO: what if this is off-screen?
|
||||
return location
|
||||
|
||||
|
||||
func collect(player: WorldPlayer) -> void:
|
||||
# Note that this animation will call `queue_free` in 5 seconds!
|
||||
explosion_player.play("explode")
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
class_name HUDParticles extends GPUParticles2D
|
||||
## 2D particle emitter with spatial logic, for emitting particles in the HUD.
|
||||
|
||||
|
||||
## Emit the given number of particles in one shot.
|
||||
func emit(_amount: int) -> void:
|
||||
amount = _amount
|
||||
emitting = true
|
||||
|
||||
|
||||
## Emit the given number of particles from the given screen location.
|
||||
func emit_at_location(_amount: int, source_location: Vector2) -> void:
|
||||
var particle_mat: ParticleProcessMaterial = process_material
|
||||
particle_mat.emission_shape_offset = Vector3(source_location.x, source_location.y, 0)
|
||||
emit(_amount)
|
||||
|
||||
|
||||
## Emit the given number of particles from the screen location of the given point in 3D space.
|
||||
func emit_spatial(_amount: int, source_location: Vector3) -> void:
|
||||
var screen_location := get_viewport().get_camera_3d().unproject_position(source_location)
|
||||
# TODO: what to do if this is outside the viewport?
|
||||
emit_at_location(_amount, screen_location)
|
|
@ -0,0 +1,50 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://dfh0bv7lwewj5"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/ui/decorations/hud_particles/hud_particles.gd" id="1_leh7k"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_mp3bg"]
|
||||
max_value = 100.0
|
||||
_data = [Vector2(0.0431211, 0), 0.0, 21.2919, 0, 0, Vector2(1, 100), 336.968, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_satut"]
|
||||
curve = SubResource("Curve_mp3bg")
|
||||
|
||||
[sub_resource type="Curve" id="Curve_a5ydw"]
|
||||
max_value = 200.0
|
||||
_data = [Vector2(0, 9.02831), 0.0, 0.618766, 0, 0, Vector2(1, 200), 450.985, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_oynpa"]
|
||||
curve = SubResource("Curve_a5ydw")
|
||||
|
||||
[sub_resource type="Curve" id="Curve_53gso"]
|
||||
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.0616016, 1), 0.0, 0.0, 0, 0, Vector2(0.761807, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 4
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_a05qh"]
|
||||
curve = SubResource("Curve_53gso")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_besmx"]
|
||||
particle_flag_disable_z = true
|
||||
direction = Vector3(0, 0, 0)
|
||||
spread = 180.0
|
||||
initial_velocity_min = 400.0
|
||||
initial_velocity_max = 600.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
radial_accel_min = -100.0
|
||||
radial_accel_max = -100.0
|
||||
radial_accel_curve = SubResource("CurveTexture_oynpa")
|
||||
damping_min = 200.0
|
||||
damping_max = 200.0
|
||||
damping_curve = SubResource("CurveTexture_satut")
|
||||
scale_curve = SubResource("CurveTexture_a05qh")
|
||||
|
||||
[node name="HUDParticles" type="GPUParticles2D"]
|
||||
emitting = false
|
||||
amount = 32
|
||||
process_material = SubResource("ParticleProcessMaterial_besmx")
|
||||
lifetime = 1.4
|
||||
one_shot = true
|
||||
explosiveness = 0.7
|
||||
script = ExtResource("1_leh7k")
|
|
@ -16,7 +16,7 @@ var player: WorldPlayer
|
|||
|
||||
@onready var club_selector: ClubSelector = %ClubSelector
|
||||
@onready var ball_selector: BallSelector = %BallSelector
|
||||
@onready var _ball_particles: GPUParticles2D = %BallParticles
|
||||
@onready var ball_particles: HUDParticles = %BallParticles
|
||||
|
||||
@onready var _curve_animation: AnimationPlayer = %CurveAnimation
|
||||
@onready var _power_animation: AnimationPlayer = %PowerAnimation
|
||||
|
@ -110,13 +110,6 @@ func hide_reset_prompt() -> void:
|
|||
_reset_prompt_animation.play_backwards("show")
|
||||
|
||||
|
||||
func emit_ball_particles(amount: int, location: Vector2) -> void:
|
||||
var particle_mat: ParticleProcessMaterial = _ball_particles.process_material
|
||||
particle_mat.emission_shape_offset = Vector3(location.x, location.y, 0)
|
||||
_ball_particles.amount = amount
|
||||
_ball_particles.emitting = true
|
||||
|
||||
|
||||
## Set the value of the life bar, potentially playing some kind of effect in response.
|
||||
##
|
||||
## To set the life bar without triggering an effect, set it directly with `life_bar.value`
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=49 format=3 uid="uid://c4ifdiohng830"]
|
||||
[gd_scene load_steps=44 format=3 uid="uid://c4ifdiohng830"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/ui/shot_hud/shot_hud.gd" id="1_x5b4c"]
|
||||
[ext_resource type="Shader" path="res://src/shaders/canvas_retro.gdshader" id="1_ybxxp"]
|
||||
|
@ -12,6 +12,8 @@
|
|||
[ext_resource type="FontFile" uid="uid://dsa0oh7c0h4pu" path="res://assets/fonts/Racing_Sans_One/RacingSansOne-Regular.ttf" id="8_bejx4"]
|
||||
[ext_resource type="Texture2D" uid="uid://tancoet1lih5" path="res://assets/ui/ball_icons/basic_icon.png" id="8_tt8i3"]
|
||||
[ext_resource type="PackedScene" uid="uid://dmciuk3pbjsae" path="res://src/ui/shot_hud/life_bar/life_bar.tscn" id="9_w1fiw"]
|
||||
[ext_resource type="PackedScene" uid="uid://dfh0bv7lwewj5" path="res://src/ui/decorations/hud_particles/hud_particles.tscn" id="11_ie5ih"]
|
||||
[ext_resource type="Texture2D" uid="uid://dtsdecae83ah3" path="res://assets/sprites/particles/ball.png" id="12_fdbqt"]
|
||||
[ext_resource type="PackedScene" uid="uid://b47goj32i6sdh" path="res://src/ui/elements/input_prompt/input_prompt.tscn" id="14_ik4gg"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_2gt87"]
|
||||
|
@ -324,51 +326,6 @@ _data = {
|
|||
"show": SubResource("Animation_x6kyr")
|
||||
}
|
||||
|
||||
[sub_resource type="Curve" id="Curve_mp3bg"]
|
||||
max_value = 100.0
|
||||
_data = [Vector2(0.0431211, 0), 0.0, 21.2919, 0, 0, Vector2(1, 100), 336.968, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_satut"]
|
||||
curve = SubResource("Curve_mp3bg")
|
||||
|
||||
[sub_resource type="Curve" id="Curve_a5ydw"]
|
||||
max_value = 200.0
|
||||
_data = [Vector2(0, 9.02831), 0.0, 0.618766, 0, 0, Vector2(1, 200), 450.985, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_oynpa"]
|
||||
curve = SubResource("Curve_a5ydw")
|
||||
|
||||
[sub_resource type="Curve" id="Curve_53gso"]
|
||||
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.0616016, 1), 0.0, 0.0, 0, 0, Vector2(0.761807, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 4
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_a05qh"]
|
||||
curve = SubResource("Curve_53gso")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_besmx"]
|
||||
particle_flag_disable_z = true
|
||||
emission_shape_offset = Vector3(800, 600, 0)
|
||||
angle_min = -720.0
|
||||
angle_max = 720.0
|
||||
direction = Vector3(0, 0, 0)
|
||||
spread = 180.0
|
||||
initial_velocity_min = 400.0
|
||||
initial_velocity_max = 600.0
|
||||
angular_velocity_min = -100.0
|
||||
angular_velocity_max = 100.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
radial_accel_min = -100.0
|
||||
radial_accel_max = -100.0
|
||||
radial_accel_curve = SubResource("CurveTexture_oynpa")
|
||||
damping_min = 200.0
|
||||
damping_max = 200.0
|
||||
damping_curve = SubResource("CurveTexture_satut")
|
||||
scale_min = 0.4
|
||||
scale_max = 0.4
|
||||
scale_curve = SubResource("CurveTexture_a05qh")
|
||||
|
||||
[sub_resource type="Animation" id="Animation_3cn2c"]
|
||||
resource_name = "RESET"
|
||||
length = 0.001
|
||||
|
@ -787,15 +744,9 @@ anchor_bottom = 0.5
|
|||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="BallParticles" type="GPUParticles2D" parent="ClubSelector/TextureRect/BallParticleContainer"]
|
||||
[node name="BallParticles" parent="ClubSelector/TextureRect/BallParticleContainer" instance=ExtResource("11_ie5ih")]
|
||||
unique_name_in_owner = true
|
||||
emitting = false
|
||||
amount = 32
|
||||
process_material = SubResource("ParticleProcessMaterial_besmx")
|
||||
texture = ExtResource("8_tt8i3")
|
||||
lifetime = 1.4
|
||||
one_shot = true
|
||||
explosiveness = 0.7
|
||||
texture = ExtResource("12_fdbqt")
|
||||
|
||||
[node name="SouthWest" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
|
|
Loading…
Reference in New Issue