Added CannonWeapon textures

This commit is contained in:
2025-11-19 15:32:03 +03:00
parent 721d38e9d1
commit 77b03e4b73
25 changed files with 443 additions and 36 deletions
@@ -1 +1,82 @@
extends AbstractWeapon
const SHOT_POSTFIX = "shot"
const IDLE_POSTFIX = "idle"
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
@onready var front_particles : GPUParticles2D = $ShotParticles/Front
@onready var left_particles : GPUParticles2D = $ShotParticles/Left
@onready var right_particles : GPUParticles2D = $ShotParticles/Right
@onready var shell_particles : GPUParticles2D = $ShellParticles
func set_belonging(belonging: Belonging) -> void:
super.set_belonging(belonging)
_init_particles()
sprite.play(PREFIXES[_belonging] + IDLE_POSTFIX)
func _init_particles() -> void:
const FRONT_OFFSET_X = 12
const LEFT_OFFSET_X = 7
const LEFT_OFFSET_Y = 5
const SHELL_OFFSET_X = -10
const SHELL_OFFSET_Y = 2
match _belonging:
Belonging.PLAYER:
front_particles.process_material.emission_shape_offset.x = FRONT_OFFSET_X
front_particles.process_material.direction = Vector3.RIGHT
left_particles.process_material.emission_shape_offset.x = LEFT_OFFSET_X
left_particles.process_material.emission_shape_offset.y = -LEFT_OFFSET_Y
left_particles.process_material.direction = Vector3.DOWN + Vector3.LEFT
right_particles.process_material.emission_shape_offset.x = LEFT_OFFSET_X
right_particles.process_material.emission_shape_offset.y = LEFT_OFFSET_Y
right_particles.process_material.direction = Vector3.UP + Vector3.LEFT
shell_particles.process_material.emission_shape_offset.x = SHELL_OFFSET_X
shell_particles.process_material.emission_shape_offset.y = SHELL_OFFSET_Y
shell_particles.process_material.direction = Vector3.UP
Belonging.ENEMY:
front_particles.process_material.emission_shape_offset.x = -FRONT_OFFSET_X
front_particles.process_material.direction = Vector3.LEFT
left_particles.process_material.emission_shape_offset.x = -LEFT_OFFSET_X
left_particles.process_material.emission_shape_offset.y = -LEFT_OFFSET_Y
left_particles.process_material.direction = Vector3.DOWN + Vector3.RIGHT
right_particles.process_material.emission_shape_offset.x = -LEFT_OFFSET_X
right_particles.process_material.emission_shape_offset.y = LEFT_OFFSET_Y
right_particles.process_material.direction = Vector3.UP + Vector3.RIGHT
shell_particles.process_material.emission_shape_offset.x = -SHELL_OFFSET_X
shell_particles.process_material.emission_shape_offset.y = -SHELL_OFFSET_Y
shell_particles.process_material.direction = Vector3.DOWN
func shoot(ship_velocity: Vector2) -> bool:
var is_shot := super.shoot(ship_velocity)
if is_shot:
sprite.play(PREFIXES[_belonging] + SHOT_POSTFIX)
_restart_particles()
return is_shot
func _restart_particles() -> void:
front_particles.restart()
left_particles.restart()
right_particles.restart()
shell_particles.restart()
func _on_animated_sprite_2d_animation_finished() -> void:
sprite.play(PREFIXES[_belonging] + IDLE_POSTFIX)
+190 -1
View File
@@ -1,18 +1,207 @@
[gd_scene load_steps=7 format=3 uid="uid://bccaoirwdkp7n"]
[gd_scene load_steps=27 format=3 uid="uid://bccaoirwdkp7n"]
[ext_resource type="PackedScene" uid="uid://1o2ta17yc5bp" path="res://game/entities/weapons/abstract_weapon.tscn" id="1_xnbws"]
[ext_resource type="PackedScene" uid="uid://cgi7wd84kjnyw" path="res://game/entities/weapons/cannon/cannon_projectile.tscn" id="2_2bjeu"]
[ext_resource type="Script" uid="uid://db24dm76b1am7" path="res://game/entities/weapons/cannon/cannon_weapon.gd" id="2_ew5um"]
[ext_resource type="Script" uid="uid://ccpriilfr3kme" path="res://game/reloaders/abstract_reloader.gd" id="3_7e2aj"]
[ext_resource type="Script" uid="uid://b255rb32vc6co" path="res://game/reloaders/firerate_reloader.gd" id="4_bv8g1"]
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="6_jfd4t"]
[ext_resource type="Texture2D" uid="uid://3w0itm7k5fxq" path="res://images/particles.png" id="7_i0ica"]
[sub_resource type="Resource" id="Resource_7e2aj"]
script = ExtResource("4_bv8g1")
firerate = 50
metadata/_custom_type_script = "uid://b255rb32vc6co"
[sub_resource type="Gradient" id="Gradient_jfd4t"]
colors = PackedColorArray(1, 0.8039216, 0.45882353, 1, 0.9372549, 0.49019608, 0.34117648, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_i0ica"]
gradient = SubResource("Gradient_jfd4t")
width = 2
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_377p4"]
resource_local_to_scene = true
lifetime_randomness = 0.4
particle_flag_disable_z = true
inherit_velocity_ratio = 0.2
spread = 30.0
initial_velocity_min = 10.0
initial_velocity_max = 20.0
gravity = Vector3(0, 0, 0)
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_i0ica"]
resource_local_to_scene = true
lifetime_randomness = 0.1
particle_flag_disable_z = true
inherit_velocity_ratio = 0.2
spread = 5.0
initial_velocity_min = 10.0
initial_velocity_max = 20.0
gravity = Vector3(0, 0, 0)
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_jfd4t"]
resource_local_to_scene = true
lifetime_randomness = 0.1
particle_flag_disable_z = true
inherit_velocity_ratio = 0.2
spread = 5.0
initial_velocity_min = 10.0
initial_velocity_max = 20.0
gravity = Vector3(0, 0, 0)
[sub_resource type="AtlasTexture" id="AtlasTexture_jfd4t"]
atlas = ExtResource("6_jfd4t")
region = Rect2(0, 160, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_i0ica"]
atlas = ExtResource("6_jfd4t")
region = Rect2(32, 160, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_377p4"]
atlas = ExtResource("6_jfd4t")
region = Rect2(64, 160, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_nrbut"]
atlas = ExtResource("6_jfd4t")
region = Rect2(96, 160, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_mk6k8"]
atlas = ExtResource("6_jfd4t")
region = Rect2(128, 160, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_fxfcx"]
atlas = ExtResource("6_jfd4t")
region = Rect2(0, 144, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_dvc0n"]
atlas = ExtResource("6_jfd4t")
region = Rect2(32, 144, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_caj01"]
atlas = ExtResource("6_jfd4t")
region = Rect2(64, 144, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_e28g8"]
atlas = ExtResource("6_jfd4t")
region = Rect2(96, 144, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_f7kmj"]
atlas = ExtResource("6_jfd4t")
region = Rect2(128, 144, 32, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_kdf62"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_jfd4t")
}],
"loop": true,
"name": &"enemy_idle",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_i0ica")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_377p4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nrbut")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_mk6k8")
}],
"loop": false,
"name": &"enemy_shot",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_fxfcx")
}],
"loop": true,
"name": &"player_idle",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_dvc0n")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_caj01")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_e28g8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_f7kmj")
}],
"loop": false,
"name": &"player_shot",
"speed": 10.0
}]
[sub_resource type="AtlasTexture" id="AtlasTexture_h76ev"]
atlas = ExtResource("7_i0ica")
region = Rect2(0, 0, 16, 16)
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_nrbut"]
resource_local_to_scene = true
lifetime_randomness = 0.5
particle_flag_disable_z = true
inherit_velocity_ratio = 1.0
spread = 15.0
initial_velocity_min = 5.0
initial_velocity_max = 15.0
gravity = Vector3(0, 0, 0)
[node name="CannonWeapon" instance=ExtResource("1_xnbws")]
script = ExtResource("2_ew5um")
sector_angle = 1
Projectile = ExtResource("2_2bjeu")
reloaders = Array[ExtResource("3_7e2aj")]([SubResource("Resource_7e2aj")])
[node name="ShotParticles" type="Node2D" parent="." index="0"]
[node name="Front" type="GPUParticles2D" parent="ShotParticles" index="0"]
emitting = false
amount = 32
texture = SubResource("GradientTexture1D_i0ica")
lifetime = 0.5
one_shot = true
preprocess = 0.1
fixed_fps = 10
process_material = SubResource("ParticleProcessMaterial_377p4")
[node name="Left" type="GPUParticles2D" parent="ShotParticles" index="1"]
emitting = false
texture = SubResource("GradientTexture1D_i0ica")
lifetime = 0.2
one_shot = true
fixed_fps = 10
process_material = SubResource("ParticleProcessMaterial_i0ica")
[node name="Right" type="GPUParticles2D" parent="ShotParticles" index="2"]
emitting = false
texture = SubResource("GradientTexture1D_i0ica")
lifetime = 0.2
one_shot = true
fixed_fps = 10
process_material = SubResource("ParticleProcessMaterial_jfd4t")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="1"]
sprite_frames = SubResource("SpriteFrames_kdf62")
animation = &"player_idle"
[node name="ShellParticles" type="GPUParticles2D" parent="." index="2"]
emitting = false
amount = 1
texture = SubResource("AtlasTexture_h76ev")
lifetime = 2.0
one_shot = true
fixed_fps = 10
process_material = SubResource("ParticleProcessMaterial_nrbut")
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]