Removed shoot() from controllers. Removed idle animation from laser

This commit is contained in:
2025-12-19 15:18:50 +03:00
parent 6fdc3dc894
commit 7bdace27a8
8 changed files with 26 additions and 105 deletions
@@ -11,6 +11,13 @@ var enemy_data : EnemyData:
@onready var controller : EnemyController = $EnemyController
func _physics_process(delta: float) -> void:
super._physics_process(delta)
if is_on_screen:
shoot()
func _add_weapon(weapon: AbstractWeapon, weapon_position: Vector2) -> void:
super._add_weapon(weapon, weapon_position)
weapon.set_belonging(AbstractWeapon.Belonging.ENEMY)
@@ -1,21 +1,31 @@
[gd_scene load_steps=4 format=3 uid="uid://dwsn0lf1e3578"]
[gd_scene load_steps=6 format=3 uid="uid://dwsn0lf1e3578"]
[ext_resource type="PackedScene" uid="uid://jvyagshykmgb" path="res://game/entities/ships/abstract_ship.tscn" id="1_28j6l"]
[ext_resource type="Script" uid="uid://byicf1t0807pq" path="res://game/entities/ships/enemies/abstract_enemy_ship.gd" id="2_fwvrd"]
[ext_resource type="Shader" uid="uid://dwh22f35u5qqi" path="res://game/entities/ships/shield.gdshader" id="3_6nnf4"]
[ext_resource type="PackedScene" uid="uid://bsqehbymixust" path="res://game/controllers/enemy_controller.tscn" id="3_l8c0n"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_dlmr1"]
resource_local_to_scene = true
shader = ExtResource("3_6nnf4")
shader_parameter/speed = 0.0
shader_parameter/scale = 20.0
shader_parameter/intensity = 1.0
[node name="AbstractEnemyShip" groups=["enemies"] instance=ExtResource("1_28j6l")]
collision_layer = 4
collision_mask = 6
script = ExtResource("2_fwvrd")
weapon_rotation = 180
[node name="ArmorSprite" parent="." index="1"]
material = SubResource("ShaderMaterial_dlmr1")
[node name="EnemyController" parent="." index="4" node_paths=PackedStringArray("ship") instance=ExtResource("3_l8c0n")]
ship = NodePath("..")
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="." index="5"]
[connection signal="accelerate" from="EnemyController" to="." method="accelerate"]
[connection signal="shoot" from="EnemyController" to="." method="shoot"]
[connection signal="screen_entered" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_entered"]
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
@@ -33,6 +33,8 @@ func _ready() -> void:
func _physics_process(delta: float) -> void:
super._physics_process(delta)
shoot()
if blink_charge < BLINK_CHARGE_MAXIMUM:
blink_charge += delta
blink_charge_indicator.value = blink_charge
@@ -103,7 +103,6 @@ position = Vector2(-11, 0)
[connection signal="accelerate" from="PlayerController" to="." method="accelerate"]
[connection signal="blink" from="PlayerController" to="." method="_blink"]
[connection signal="shoot" from="PlayerController" to="." method="shoot"]
[connection signal="armor_updated" from="Health" to="." method="_on_armor_updated"]
[connection signal="hull_updated" from="Health" to="." method="_on_hull_updated"]
[connection signal="shield_updated" from="Health" to="." method="_on_shield_updated"]
+2 -19
View File
@@ -1,27 +1,20 @@
extends AbstractWeapon
@onready var idle_sprite : AnimatedSprite2D = $IdleAnimatedSprite
@onready var firing_sprite : AnimatedSprite2D = $FiringAnimatedSprite
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
@onready var cooldown_timer : Timer = $CooldownTimer
func _ready() -> void:
_switch_sprite(false)
func set_belonging(belonging: Belonging) -> void:
super.set_belonging(belonging)
idle_sprite.play(PREFIXES[_belonging])
firing_sprite.play(PREFIXES[_belonging])
sprite.play(PREFIXES[_belonging])
func shoot(ship_velocity: Vector2) -> bool:
var is_shot := super.shoot(ship_velocity)
if is_shot:
_can_shoot = false
_switch_sprite(true)
cooldown_timer.start()
return is_shot
@@ -29,13 +22,3 @@ func shoot(ship_velocity: Vector2) -> bool:
func _on_cooldown_timer_timeout() -> void:
_can_shoot = true
_switch_sprite(false)
func _switch_sprite(firing: bool) -> void:
if firing:
idle_sprite.hide()
firing_sprite.show()
else:
idle_sprite.show()
firing_sprite.hide()
+3 -77
View File
@@ -1,79 +1,10 @@
[gd_scene load_steps=23 format=3 uid="uid://def1alrel4ioo"]
[gd_scene load_steps=14 format=3 uid="uid://def1alrel4ioo"]
[ext_resource type="PackedScene" uid="uid://1o2ta17yc5bp" path="res://game/entities/weapons/abstract_weapon.tscn" id="1_pki4x"]
[ext_resource type="PackedScene" uid="uid://cmni0xrbbfcy5" path="res://game/entities/weapons/laser/laser_projectile.tscn" id="2_fecho"]
[ext_resource type="Script" uid="uid://bxr150at8ul2a" path="res://game/entities/weapons/laser/laser_weapon.gd" id="2_lbdvb"]
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="6_c8tb4"]
[sub_resource type="AtlasTexture" id="AtlasTexture_4a3il"]
atlas = ExtResource("6_c8tb4")
region = Rect2(0, 80, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_n1iu2"]
atlas = ExtResource("6_c8tb4")
region = Rect2(32, 80, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_kgblc"]
atlas = ExtResource("6_c8tb4")
region = Rect2(64, 80, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_f2vvu"]
atlas = ExtResource("6_c8tb4")
region = Rect2(96, 80, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_7rt33"]
atlas = ExtResource("6_c8tb4")
region = Rect2(0, 64, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_n02tm"]
atlas = ExtResource("6_c8tb4")
region = Rect2(32, 64, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_7q2cb"]
atlas = ExtResource("6_c8tb4")
region = Rect2(64, 64, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qatwk"]
atlas = ExtResource("6_c8tb4")
region = Rect2(96, 64, 32, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_qjjka"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_4a3il")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_n1iu2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kgblc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_f2vvu")
}],
"loop": true,
"name": &"enemy",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_7rt33")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_n02tm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_7q2cb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qatwk")
}],
"loop": true,
"name": &"player",
"speed": 10.0
}]
[sub_resource type="AtlasTexture" id="AtlasTexture_dggsl"]
atlas = ExtResource("6_c8tb4")
region = Rect2(128, 80, 32, 16)
@@ -149,17 +80,12 @@ bullet_per_shot = 2
Projectile = ExtResource("2_fecho")
type = 2
[node name="IdleAnimatedSprite" type="AnimatedSprite2D" parent="." index="0"]
position = Vector2(3, 0)
sprite_frames = SubResource("SpriteFrames_qjjka")
animation = &"player"
[node name="FiringAnimatedSprite" type="AnimatedSprite2D" parent="." index="1"]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0"]
position = Vector2(3, 0)
sprite_frames = SubResource("SpriteFrames_c8tb4")
animation = &"player"
[node name="CooldownTimer" type="Timer" parent="." index="2"]
[node name="CooldownTimer" type="Timer" parent="." index="1"]
process_callback = 0
wait_time = 0.05
one_shot = true