From 99202166ebf10a0ed06bb4de0f2a1eda49edb616 Mon Sep 17 00:00:00 2001 From: Luna Brovchuk Date: Sun, 1 Oct 2023 17:24:09 +0200 Subject: [PATCH] Fix Ghost's Aim Trail --- src/models/enemies/ghost/Ghost.tscn | 23 ++++++++++--------- src/models/enemies/ghost/ghost.gd | 7 ++++++ .../sprites/aiming/aiming_spriteframes.tres | 4 ++-- src/scenes/game/Game.tscn | 6 +---- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/models/enemies/ghost/Ghost.tscn b/src/models/enemies/ghost/Ghost.tscn index aa033cc..3dd4272 100644 --- a/src/models/enemies/ghost/Ghost.tscn +++ b/src/models/enemies/ghost/Ghost.tscn @@ -5,17 +5,27 @@ [ext_resource path="res://src/models/enemies/ghost/sprites/aiming/aiming_spriteframes.tres" type="SpriteFrames" id=3] [sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 5.5, 5.5 ) +extents = Vector2( 7, 9 ) [node name="Ghost" type="KinematicBody2D" groups=["enemy", "ghost"]] z_index = 2 script = ExtResource( 2 ) +[node name="Aim" type="AnimatedSprite" parent="."] +position = Vector2( 9, 14 ) +frames = ExtResource( 3 ) +animation = "idle" +frame = 7 +playing = true +centered = false +offset = Vector2( -6, -6 ) +flip_h = true + [node name="Sprite" type="AnimatedSprite" parent="."] use_parent_material = true frames = ExtResource( 1 ) animation = "idle" -frame = 1 +frame = 2 playing = true centered = false @@ -24,12 +34,3 @@ centered = false [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] position = Vector2( 8.5, 13.5 ) shape = SubResource( 1 ) - -[node name="AnimatedSprite" type="AnimatedSprite" parent="."] -position = Vector2( 9, 13 ) -frames = ExtResource( 3 ) -animation = "idle" -frame = 8 -playing = true -centered = false -flip_h = true diff --git a/src/models/enemies/ghost/ghost.gd b/src/models/enemies/ghost/ghost.gd index c0d7a54..c6504a0 100644 --- a/src/models/enemies/ghost/ghost.gd +++ b/src/models/enemies/ghost/ghost.gd @@ -11,14 +11,21 @@ func _ready(): func _physics_process(delta): var dist = global_position.distance_to(player.global_position) if dist > 25 and dash_target == Vector2.ZERO: + $Aim.visible = false global_position = global_position.move_toward(player.global_position, dist * delta * speed_multiplier) else: if dash_target == Vector2.ZERO: var angle = global_position.angle_to_point(player.global_position) + PI + $Aim.rotation_degrees = 0 + $Aim.rotate(angle) + $Aim.visible = true + $Aim.frame = 0 + $Aim.play("idle") dash_target = global_position + Vector2(60, 0).rotated(angle) if dash_target != Vector2.ZERO: dash_timer += delta if dash_timer >= 1.0: + $Aim.visible = false dash_timer = 0 dashing = true diff --git a/src/models/enemies/ghost/sprites/aiming/aiming_spriteframes.tres b/src/models/enemies/ghost/sprites/aiming/aiming_spriteframes.tres index c44b7bf..c9888ea 100644 --- a/src/models/enemies/ghost/sprites/aiming/aiming_spriteframes.tres +++ b/src/models/enemies/ghost/sprites/aiming/aiming_spriteframes.tres @@ -36,8 +36,8 @@ region = Rect2( 0, 77, 60, 11 ) [resource] animations = [ { -"frames": [ null, SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ], +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ], "loop": false, "name": "idle", -"speed": 18.0 +"speed": 16.0 } ] diff --git a/src/scenes/game/Game.tscn b/src/scenes/game/Game.tscn index 88c6a6a..94a15ca 100644 --- a/src/scenes/game/Game.tscn +++ b/src/scenes/game/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=2] +[gd_scene load_steps=21 format=2] [ext_resource path="res://src/scenes/menu/background/background.png" type="Texture" id=1] [ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2] @@ -16,7 +16,6 @@ [ext_resource path="res://src/models/enemies/bat/Bat.tscn" type="PackedScene" id=14] [ext_resource path="res://src/models/enemies/ghost/Ghost.tscn" type="PackedScene" id=15] [ext_resource path="res://src/scenes/game/spell_recharge_bar.gd" type="Script" id=16] -[ext_resource path="res://src/models/enemies/rat/Rat.tscn" type="PackedScene" id=17] [sub_resource type="RectangleShape2D" id=2] extents = Vector2( 10, 60 ) @@ -89,9 +88,6 @@ position = Vector2( 142, 54 ) [node name="Ghost" parent="View/Enemies" instance=ExtResource( 15 )] position = Vector2( 509, 100 ) -[node name="Rat" parent="View/Enemies" instance=ExtResource( 17 )] -position = Vector2( 93, 72 ) - [node name="UIWrapper" type="CanvasLayer" parent="."] layer = 3