Skip to content

Commit

Permalink
Fix player trail appearance in Dodge The Creeps (#986)
Browse files Browse the repository at this point in the history
Nazarwadim authored Oct 30, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 7af99c5 commit 40ce32c
Showing 3 changed files with 29 additions and 16 deletions.
3 changes: 2 additions & 1 deletion 2d/dodge_the_creeps/Player.gd
Original file line number Diff line number Diff line change
@@ -33,11 +33,12 @@ func _process(delta):
if velocity.x != 0:
$AnimatedSprite2D.animation = &"right"
$AnimatedSprite2D.flip_v = false
$Trail.rotation = 0
$AnimatedSprite2D.flip_h = velocity.x < 0
elif velocity.y != 0:
$AnimatedSprite2D.animation = &"up"
$AnimatedSprite2D.flip_v = velocity.y > 0

$Trail.rotation = PI if velocity.y > 0 else 0

This comment has been minimized.

Copy link
@TroubleFait

TroubleFait Jan 31, 2024

This produces a warning:

W 0:00:00:0318   Values of the ternary conditional are not mutually compatible.
  <GDScript Error>INCOMPATIBLE_TERNARY
  <GDScript Source>player.gd:41

This comment has been minimized.

Copy link
@aaronfranke

aaronfranke Jan 31, 2024

Member

Yes, the latter value should be 0.0 instead.


func start(pos):
position = pos
38 changes: 25 additions & 13 deletions 2d/dodge_the_creeps/Player.tscn
Original file line number Diff line number Diff line change
@@ -8,12 +8,24 @@

[sub_resource type="SpriteFrames" id="1"]
animations = [{
"frames": [ExtResource( "2" ), ExtResource( "3" )],
"frames": [{
"duration": 1.0,
"texture": ExtResource("2")
}, {
"duration": 1.0,
"texture": ExtResource("3")
}],
"loop": true,
"name": &"right",
"speed": 5.0
}, {
"frames": [ExtResource( "4" ), ExtResource( "5" )],
"frames": [{
"duration": 1.0,
"texture": ExtResource("4")
}, {
"duration": 1.0,
"texture": ExtResource("5")
}],
"loop": true,
"name": &"up",
"speed": 5.0
@@ -27,37 +39,37 @@ height = 68.0
colors = PackedColorArray(1, 1, 1, 0.501961, 1, 1, 1, 0)

[sub_resource type="GradientTexture1D" id="4"]
gradient = SubResource( "3" )
gradient = SubResource("3")

[sub_resource type="Curve" id="5"]
_data = [Vector2(0.00501098, 0.5), 0.0, 0.0, 0, 0, Vector2(0.994989, 0.324), 0.0, 0.0, 0, 0]
point_count = 2

[sub_resource type="CurveTexture" id="6"]
curve = SubResource( "5" )
curve = SubResource("5")

[sub_resource type="ParticlesMaterial" id="7"]
[sub_resource type="ParticleProcessMaterial" id="7"]
gravity = Vector3(0, 0, 0)
scale_curve = SubResource( "6" )
color_ramp = SubResource( "4" )
scale_curve = SubResource("6")
color_ramp = SubResource("4")

[node name="Player" type="Area2D"]
z_index = 10
script = ExtResource( "1" )
script = ExtResource("1")

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
scale = Vector2(0.5, 0.5)
frames = SubResource( "1" )
sprite_frames = SubResource("1")
animation = &"right"

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( "2" )
shape = SubResource("2")

[node name="Trail" type="GPUParticles2D" parent="."]
z_index = -1
amount = 10
process_material = SubResource("7")
texture = ExtResource("2")
speed_scale = 2.0
local_coords = false
process_material = SubResource( "7" )
texture = ExtResource( "2" )

[connection signal="body_entered" from="." to="." method="_on_Player_body_entered"]
4 changes: 2 additions & 2 deletions 2d/dodge_the_creeps/project.godot
Original file line number Diff line number Diff line change
@@ -17,10 +17,10 @@ and avoid the enemies for as long as possible.
This is a finished version of the game featured in the 'Your first 2D game'
tutorial in the documentation. For more details, consider
following the tutorial in the documentation."
config/tags=PackedStringArray("2d", "demo", "official")
run/main_scene="res://Main.tscn"
config/features=PackedStringArray("4.0")
config/features=PackedStringArray("4.1")
config/icon="res://icon.webp"
config/tags=PackedStringArray("2d", "demo", "official")

[debug]

0 comments on commit 40ce32c

Please sign in to comment.