Skip to content

Commit

Permalink
Add puffs when the player walks/runs, closes #60
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanLovato committed Oct 14, 2018
1 parent dc7efcb commit e3439a6
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 81 deletions.
15 changes: 14 additions & 1 deletion actors/player/Player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,20 @@ tracks/1/keys = {
"method": "play_random"
} ]
}
tracks/2/type = "method"
tracks/2/path = NodePath("StateMachine/Move")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0.3 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "spawn_dust"
} ]
}

[sub_resource type="DynamicFont" id=9]

Expand Down Expand Up @@ -363,7 +377,6 @@ shape = SubResource( 1 )

[node name="StateMachine" type="Node" parent="." index="2"]

editor/display_folded = true
script = ExtResource( 4 )
active = false

Expand Down
13 changes: 13 additions & 0 deletions actors/player/states/motion/on_ground/Move.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ signal last_moved(direction)
export(float) var MAX_WALK_SPEED = 450
export(float) var MAX_RUN_SPEED = 700

const DustRun = preload("res://particles/dust_puffs/DustRun.tscn")
const DustWalk = preload("res://particles/dust_puffs/DustWalk.tscn")

func enter():
speed = 0.0
velocity = Vector2()
Expand Down Expand Up @@ -33,3 +36,13 @@ func update(delta):
if speed == MAX_RUN_SPEED and collision_info.collider.is_in_group("environment"):
emit_signal("last_moved", input_direction)
emit_signal("finished", 'bump')

func spawn_dust():
var dust
match speed:
MAX_RUN_SPEED:
dust = DustRun.instance()
MAX_WALK_SPEED:
dust = DustWalk.instance()
owner.add_child(dust)
dust.start()
2 changes: 1 addition & 1 deletion interface/menus/inventory/ItemsMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[ext_resource path="res://interface/menus/inventory/ItemGrid.gd" type="Script" id=4]
[ext_resource path="res://interface/menus/inventory/user_select/UserSelectMenu.tscn" type="PackedScene" id=5]

[node name="ItemsMenu" type="Control" index="0"]
[node name="ItemsMenu" type="Control"]

anchor_left = 0.0
anchor_top = 0.0
Expand Down
3 changes: 0 additions & 3 deletions interface/menus/pause/PauseMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
[ext_resource path="res://interface/menus/shared/Button.tscn" type="PackedScene" id=3]
[ext_resource path="res://interface/menus/inventory/InventoryMenu.tscn" type="PackedScene" id=4]




[node name="PauseMenu" instance=ExtResource( 1 )]

script = ExtResource( 2 )
Expand Down
6 changes: 6 additions & 0 deletions particles/SelfDestructingParticles.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends Particles2D

func start():
emitting = true
yield(get_tree().create_timer(lifetime * speed_scale * 1.2), "timeout")
queue_free()
82 changes: 73 additions & 9 deletions particles/dust_puffs/DustRun.tscn
Original file line number Diff line number Diff line change
@@ -1,19 +1,82 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=8 format=2]

[ext_resource path="res://dust_puffs/dust_puffs_particle.tres" type="Material" id=1]
[ext_resource path="res://dust_puffs/puff_stylized.png" type="Texture" id=2]
[ext_resource path="res://particles/dust_puffs/puff_stylized.png" type="Texture" id=1]
[ext_resource path="res://particles/SelfDestructingParticles.gd" type="Script" id=2]

[sub_resource type="Gradient" id=1]

offsets = PoolRealArray( 0, 0.0602007, 0.769231, 1 )
colors = PoolColorArray( 0.308594, 0.233027, 0.144653, 0, 0.574219, 0.435676, 0.273651, 1, 0.598236, 0.472648, 0.325774, 1, 0.596078, 0.470588, 0.32549, 0 )

[sub_resource type="GradientTexture" id=2]

flags = 4
gradient = SubResource( 1 )
width = 256

[sub_resource type="Curve" id=3]

min_value = 0.0
max_value = 1.0
bake_resolution = 100
_data = [ Vector2( 0, 0.349609 ), 0.0, 1.47649, 0, 0, Vector2( 0.908748, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.628906 ), -4.5017, 0.0, 0, 0 ]

[sub_resource type="CurveTexture" id=4]

flags = 4
width = 2048
curve = SubResource( 3 )

[sub_resource type="ParticlesMaterial" id=5]

render_priority = 0
trail_divisor = 1
emission_shape = 1
emission_sphere_radius = 10.0
flag_align_y = false
flag_rotate_y = false
flag_disable_z = true
spread = 120.0
flatness = 1.0
gravity = Vector3( 0, 0, 0 )
initial_velocity = 30.0
initial_velocity_random = 0.4
angular_velocity = 120.0
angular_velocity_random = 0.7
orbit_velocity = 0.0
orbit_velocity_random = 0.0
linear_accel = -10.0
linear_accel_random = 0.0
radial_accel = 0.0
radial_accel_random = 0.0
tangential_accel = 0.0
tangential_accel_random = 0.0
damping = 0.0
damping_random = 0.0
angle = 360.0
angle_random = 1.0
scale = 0.6
scale_random = 0.1
scale_curve = SubResource( 4 )
color_ramp = SubResource( 2 )
hue_variation = 0.0
hue_variation_random = 0.0
anim_speed = 0.0
anim_speed_random = 0.0
anim_offset = 1.0
anim_offset_random = 1.0
anim_loop = false
_sections_unfolded = [ "Color", "Scale" ]

[node name="DustRun" type="Particles2D" index="0"]

show_behind_parent = true
position = Vector2( 1, 0 )
rotation = -1.5708
emitting = true
amount = 8
emitting = false
amount = 12
lifetime = 1.0
one_shot = false
one_shot = true
preprocess = 0.0
speed_scale = 2.0
explosiveness = 0.95
Expand All @@ -23,11 +86,12 @@ fract_delta = true
visibility_rect = Rect2( -400, -400, 800, 800 )
local_coords = false
draw_order = 0
process_material = ExtResource( 1 )
texture = ExtResource( 2 )
process_material = SubResource( 5 )
texture = ExtResource( 1 )
normal_map = null
h_frames = 1
v_frames = 1
_sections_unfolded = [ "Drawing", "Material", "Process Material", "Textures", "Time", "Transform", "Visibility" ]
script = ExtResource( 2 )
_sections_unfolded = [ "Drawing", "Material", "Process Material", "Textures", "Time", "Transform", "Visibility", "Z Index" ]


13 changes: 8 additions & 5 deletions particles/dust_puffs/DustWalk.tscn
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]

[ext_resource path="res://dust_puffs/dust_puffs_particle.tres" type="Material" id=1]
[ext_resource path="res://dust_puffs/puff_stylized.png" type="Texture" id=2]
[ext_resource path="res://particles/dust_puffs/dust_puffs_particle.tres" type="Material" id=1]
[ext_resource path="res://particles/dust_puffs/puff_stylized.png" type="Texture" id=2]
[ext_resource path="res://particles/SelfDestructingParticles.gd" type="Script" id=3]

[node name="DustWalk" type="Particles2D" index="0"]

show_behind_parent = true
position = Vector2( 1, 0 )
rotation = -1.5708
emitting = true
emitting = false
amount = 8
lifetime = 1.0
one_shot = false
one_shot = true
preprocess = 0.0
speed_scale = 1.4
explosiveness = 0.95
Expand All @@ -25,6 +27,7 @@ texture = ExtResource( 2 )
normal_map = null
h_frames = 1
v_frames = 1
script = ExtResource( 3 )
_sections_unfolded = [ "Drawing", "Material", "Time", "Transform", "Visibility" ]


4 changes: 2 additions & 2 deletions particles/dust_puffs/dust_puffs_particle.tres
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ damping = 0.0
damping_random = 0.0
angle = 360.0
angle_random = 1.0
scale = 0.25
scale = 0.5
scale_random = 0.0
scale_curve = SubResource( 4 )
color_ramp = SubResource( 2 )
Expand All @@ -63,5 +63,5 @@ anim_speed_random = 0.0
anim_offset = 1.0
anim_offset_random = 1.0
anim_loop = false
_sections_unfolded = [ "Emission Shape" ]
_sections_unfolded = [ "Emission Shape", "Scale" ]

25 changes: 0 additions & 25 deletions particles/getting_started/YourFirstParticles.tscn

This file was deleted.

Binary file removed particles/getting_started/star_small.png
Binary file not shown.
29 changes: 0 additions & 29 deletions particles/getting_started/star_small.png.import

This file was deleted.

9 changes: 3 additions & 6 deletions particles/smoke/EnemySmokeScreen.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://smoke/smoke_screen_particle.tres" type="Material" id=1]
[ext_resource path="res://smoke/smoke.png" type="Texture" id=2]
[ext_resource path="res://smoke/particles_player.gd" type="Script" id=3]
[gd_scene load_steps=3 format=2]

[ext_resource path="res://particles/smoke/smoke_screen_particle.tres" type="Material" id=1]
[ext_resource path="res://particles/smoke/smoke.png" type="Texture" id=2]

[node name="EnemySmokeScreen" type="Particles2D" index="0"]

Expand All @@ -26,7 +24,6 @@ texture = ExtResource( 2 )
normal_map = null
h_frames = 1
v_frames = 1
script = ExtResource( 3 )
_sections_unfolded = [ "Drawing", "Process Material", "Textures", "Time" ]

[node name="SmokeDarker" type="Particles2D" parent="." index="0"]
Expand Down

0 comments on commit e3439a6

Please sign in to comment.