From ddffee61af9242c493dae432cf562498f3b0fff6 Mon Sep 17 00:00:00 2001 From: Just Dzhi Date: Sun, 1 Oct 2023 22:37:20 +0400 Subject: [PATCH] player particles & bat flip --- res/shaders/colorize.tres | 4 ++-- src/models/enemies/bat/bat.gd | 5 ++++- src/models/player/Player.tscn | 17 ++++++++++++++--- src/models/player/player.gd | 4 ++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/res/shaders/colorize.tres b/res/shaders/colorize.tres index dcdce01..f7d36b5 100644 --- a/res/shaders/colorize.tres +++ b/res/shaders/colorize.tres @@ -15,5 +15,5 @@ void fragment(){ [resource] shader = SubResource( 3 ) -shader_param/active = true -shader_param/color = Color( 1, 1, 1, 0 ) +shader_param/active = false +shader_param/color = Color( 1, 1, 1, 1 ) diff --git a/src/models/enemies/bat/bat.gd b/src/models/enemies/bat/bat.gd index 96dc75e..bb677b3 100644 --- a/src/models/enemies/bat/bat.gd +++ b/src/models/enemies/bat/bat.gd @@ -7,7 +7,10 @@ onready var player = $"../../Player" func _ready(): hp = 15 - + +func _process(delta): + $Sprite.flip_h = true if player.global_position.x > self.global_position.x else false + func _physics_process(_delta): var player_position = player.global_position + Vector2(12, 12) var angle = get_angle_to(player_position) diff --git a/src/models/player/Player.tscn b/src/models/player/Player.tscn index 780c786..879a21b 100644 --- a/src/models/player/Player.tscn +++ b/src/models/player/Player.tscn @@ -5,10 +5,10 @@ [ext_resource path="res://res/shaders/colorize.tres" type="Material" id=3] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 4, 4 ) +extents = Vector2( 3.5, 3.5 ) [sub_resource type="RectangleShape2D" id=2] -extents = Vector2( 7, 11 ) +extents = Vector2( 3.5, 9 ) [sub_resource type="Animation" id=4] resource_name = "RESET" @@ -48,7 +48,7 @@ tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 0, 0.9 ), +"times": PoolRealArray( 0, 2 ), "transitions": PoolRealArray( 1, 1 ), "update": 1, "values": [ true, false ] @@ -97,4 +97,15 @@ autoplay = "RESET" anims/RESET = SubResource( 4 ) anims/damage = SubResource( 3 ) +[node name="CPUParticles2D" type="CPUParticles2D" parent="."] +position = Vector2( 10, 23 ) +emitting = false +amount = 12 +lifetime_randomness = 1.0 +local_coords = false +direction = Vector2( -1, 0 ) +gravity = Vector2( 0, -10 ) +initial_velocity = 8.0 +color = Color( 0.458824, 0.458824, 0.458824, 1 ) + [connection signal="area_entered" from="EnemyCollision" to="." method="area_entered"] diff --git a/src/models/player/player.gd b/src/models/player/player.gd index a069b22..6d89cc4 100644 --- a/src/models/player/player.gd +++ b/src/models/player/player.gd @@ -94,6 +94,10 @@ func _process(_delta): $Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run") if abs(velocity.x) > 10: $Sprite.flip_h = true if velocity.x < 0 else false + $CPUParticles2D.emitting = true + $CPUParticles2D.direction.x = 1 if velocity.x < 0 else -1 + else: + $CPUParticles2D.emitting = false update()