Reworked other weapons

This commit is contained in:
2025-11-26 21:29:57 +03:00
parent c3c199a9f9
commit 79d942b803
20 changed files with 74 additions and 76 deletions
+8 -2
View File
@@ -32,17 +32,23 @@ signal destroyed
@export_range(0, 1000) var mass : int = 0
@export_range(0, 360) var weapon_rotation : int = 0
@export var weapon_positions: Array[Vector2]
var weapon_positions: Array[Vector2]
var _weapons : Array[AbstractWeapon]
func _ready() -> void:
for slot in $WeaponSlots.get_children():
if slot is Node2D:
weapon_positions.append(slot.global_position - global_position)
for pos in weapon_positions:
var weapon : AbstractWeapon = WEAPONS.pick_random().instantiate()
weapon.position = pos
weapon.rotation = deg_to_rad(weapon_rotation)
weapon.rotation_degrees = weapon_rotation
add_child(weapon)
_weapons.append(weapon)
+2
View File
@@ -22,4 +22,6 @@ shape = SubResource("CircleShape2D_xxtvk")
[node name="HeathBar" parent="." node_paths=PackedStringArray("health") instance=ExtResource("3_l62e5")]
health = NodePath("../Health")
[node name="WeaponSlots" type="Node2D" parent="."]
[connection signal="depleted" from="Health" to="." method="_on_health_depleted"]
@@ -16,7 +16,6 @@ acceleration = 30
deceleration = 18
max_speed = 60
mass = 600
weapon_positions = Array[Vector2]([Vector2(0, 16), Vector2(0, 0), Vector2(0, -16)])
[node name="Sprite2D" parent="." index="0"]
texture = SubResource("PlaceholderTexture2D_cuapu")
@@ -34,3 +33,11 @@ offset_bottom = 30.0
[node name="VisibleOnScreenNotifier2D" parent="." index="5"]
rect = Rect2(-29, -21, 58, 42)
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
position = Vector2(0, -13)
[node name="Second" type="Node2D" parent="WeaponSlots" index="1"]
[node name="Third" type="Node2D" parent="WeaponSlots" index="2"]
position = Vector2(0, 13)
@@ -16,7 +16,6 @@ acceleration = 92
deceleration = 46
max_speed = 92
mass = 250
weapon_positions = Array[Vector2]([Vector2(0, 10), Vector2(0, -10)])
[node name="Sprite2D" parent="." index="0"]
texture = SubResource("PlaceholderTexture2D_4jmkv")
@@ -33,3 +32,9 @@ offset_bottom = 30.0
[node name="VisibleOnScreenNotifier2D" parent="." index="5"]
rect = Rect2(-13, -21, 26, 42)
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
position = Vector2(0, -10)
[node name="Second" type="Node2D" parent="WeaponSlots" index="1"]
position = Vector2(0, 10)
@@ -15,7 +15,6 @@ acceleration = 180
deceleration = 80
max_speed = 120
mass = 100
weapon_positions = Array[Vector2]([Vector2(0, 0)])
[node name="Sprite2D" parent="." index="0"]
texture = SubResource("PlaceholderTexture2D_bw04d")
@@ -33,3 +32,6 @@ offset_bottom = 14.0
[node name="VisibleOnScreenNotifier2D" parent="." index="5"]
rect = Rect2(-13, -5, 26, 10)
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
position = Vector2(6, 0)
+7 -1
View File
@@ -17,7 +17,7 @@ acceleration = 92
deceleration = 46
max_speed = 92
mass = 250
weapon_positions = Array[Vector2]([Vector2(-2, 18), Vector2(-2, -18)])
weapon_rotation = null
[node name="Sprite2D" parent="." index="0"]
texture = ExtResource("3_uf2n1")
@@ -35,5 +35,11 @@ offset_bottom = 22.0
[node name="PlayerController" parent="." index="4" instance=ExtResource("3_4mjo1")]
[node name="First" type="Node2D" parent="WeaponSlots" index="0"]
position = Vector2(-2, 8)
[node name="Second" type="Node2D" parent="WeaponSlots" index="1"]
position = Vector2(-2, -8)
[connection signal="accelerate" from="PlayerController" to="." method="accelerate"]
[connection signal="shoot" from="PlayerController" to="." method="_on_player_controller_shoot"]
+4 -1
View File
@@ -13,6 +13,9 @@ enum Type { SHORT_RANGE, MEDIUM_RANGE, LONG_RANGE, HOMING, MINES }
@export var type := Type.MEDIUM_RANGE
@onready var muzzle : Node2D = $Muzzle
const PREFIXES := {
Belonging.PLAYER: "player",
Belonging.ENEMY: "enemy",
@@ -46,7 +49,7 @@ func shoot(ship_velocity: Vector2) -> bool:
func _get_projectile_position() -> Vector2:
return Vector2.ZERO
return muzzle.global_position - global_position
func _create_projectile(ship_velocity: Vector2) -> AbstractProjectile:
@@ -5,3 +5,5 @@
[node name="AbstractWeapon" type="Node2D"]
z_index = 2
script = ExtResource("1_x30ps")
[node name="Muzzle" type="Node2D" parent="."]
@@ -7,7 +7,6 @@ extends AbstractWeapon
@onready var right_particles : GPUParticles2D = $ShotParticles/Right
@onready var shell_particles : GPUParticles2D = $ShellParticles
@onready var cooldown_timer : Timer = $CooldownTimer
@onready var muzzle : Node2D = $Muzzle
func set_belonging(belonging: Belonging) -> void:
@@ -27,10 +26,6 @@ func shoot(ship_velocity: Vector2) -> bool:
return is_shot
func _get_projectile_position() -> Vector2:
return muzzle.position
func _restart_particles() -> void:
front_particles.restart()
left_particles.restart()
@@ -211,7 +211,7 @@ process_material = SubResource("ParticleProcessMaterial_nrbut")
wait_time = 1.2
one_shot = true
[node name="Muzzle" type="Node2D" parent="." index="4"]
[node name="Muzzle" parent="." index="4"]
position = Vector2(20, 0)
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
@@ -49,3 +49,6 @@ Projectile = ExtResource("2_ylc0n")
position = Vector2(6, 0)
sprite_frames = SubResource("SpriteFrames_pjn33")
animation = &"player_idle"
[node name="Muzzle" parent="." index="1"]
position = Vector2(14, 0)
@@ -6,12 +6,12 @@ extends AbstractWeapon
@onready var cooldown_timer : Timer = $CooldownTimer
@onready var particles : Array[GPUParticles2D] = [
$RightParticles, $LeftParticles,
$LeftParticles, $RightParticles,
]
var _particles_index := 0
@onready var muzzles : Array[Node2D] = [
$RightMuzzle, $LeftMuzzle,
$Muzzle, $SecondMuzzle,
]
var _muzzle_index := 0
@@ -48,7 +48,7 @@ func _restart_particles() -> void:
func _get_projectile_position() -> Vector2:
var projectile_position := muzzles[_muzzle_index].position
var projectile_position := muzzles[_muzzle_index].global_position - global_position
_muzzle_index += 1
if _muzzle_index >= muzzles.size():
_muzzle_index = 0
@@ -78,10 +78,10 @@ texture = SubResource("AtlasTexture_ylgjm")
wait_time = 0.5
one_shot = true
[node name="LeftMuzzle" type="Node2D" parent="." index="5"]
position = Vector2(12, -3)
[node name="Muzzle" parent="." index="5"]
position = Vector2(11, -3)
[node name="RightMuzzle" type="Node2D" parent="." index="6"]
position = Vector2(12, 3)
[node name="SecondMuzzle" type="Node2D" parent="." index="6"]
position = Vector2(11, 3)
[connection signal="timeout" from="CooldownTimer" to="." method="_on_cooldown_timer_timeout"]
@@ -119,6 +119,7 @@ Projectile = ExtResource("2_7y446")
type = 4
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0"]
position = Vector2(-7, 0)
sprite_frames = SubResource("SpriteFrames_wwpdh")
animation = &"player_shot"
@@ -21,18 +21,6 @@ func shoot(ship_velocity: Vector2) -> bool:
return is_shot
func _get_projectile_position() -> Vector2:
var projectile_position : Vector2
match _belonging:
Belonging.PLAYER:
projectile_position = Vector2(-5, 2)
Belonging.ENEMY:
projectile_position = Vector2(5, -2)
return projectile_position
func _on_animated_sprite_2d_animation_finished() -> void:
sprite.play(PREFIXES[_belonging] + RELOAD_POSTFIX)
@@ -101,6 +101,7 @@ sector_angle = 2
Projectile = ExtResource("2_yluvp")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0"]
position = Vector2(8, 0)
sprite_frames = SubResource("SpriteFrames_hyw35")
animation = &"player_reloading"
@@ -109,5 +110,8 @@ process_callback = 0
wait_time = 0.4
one_shot = true
[node name="Muzzle" parent="." index="2"]
position = Vector2(9, 2)
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
[connection signal="timeout" from="CooldownTimer" to="." method="_on_cooldown_timer_timeout"]
@@ -1,13 +1,10 @@
[gd_scene load_steps=23 format=3 uid="uid://do6h77gmnreho"]
[gd_scene load_steps=22 format=3 uid="uid://do6h77gmnreho"]
[ext_resource type="PackedScene" uid="uid://1o2ta17yc5bp" path="res://game/entities/weapons/abstract_weapon.tscn" id="1_0nxvu"]
[ext_resource type="Script" uid="uid://drnofu4ium56e" path="res://game/entities/weapons/railgun/railgun_weapon.gd" id="1_5nhwg"]
[ext_resource type="PackedScene" uid="uid://bab3bopsw74cb" path="res://game/entities/weapons/railgun/railgun_projectile.tscn" id="2_cbsia"]
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="4_qxcog"]
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_dra6h"]
size = Vector2(10, 7)
[sub_resource type="AtlasTexture" id="AtlasTexture_qxcog"]
atlas = ExtResource("4_qxcog")
region = Rect2(0, 112, 32, 16)
@@ -159,11 +156,12 @@ script = ExtResource("1_5nhwg")
Projectile = ExtResource("2_cbsia")
type = 2
[node name="Sprite2D" type="Sprite2D" parent="." index="0"]
texture = SubResource("PlaceholderTexture2D_dra6h")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="1"]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0"]
position = Vector2(5, 0)
sprite_frames = SubResource("SpriteFrames_caa1b")
animation = &"enemy_reloading"
[node name="Muzzle" parent="." index="1"]
position = Vector2(11, 0)
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
@@ -10,8 +10,6 @@ extends AbstractWeapon
func set_belonging(belonging: Belonging) -> void:
super.set_belonging(belonging)
_init_particles()
sprite.play(PREFIXES[_belonging] + IDLE_POSTFIX)
@@ -26,29 +24,6 @@ func shoot(ship_velocity: Vector2) -> bool:
return is_shot
func _init_particles() -> void:
const SHOT_OFFSET_X = 11
const SHELL_OFFSET_X = -8
const SHELL_OFFSET_Y = 1
match _belonging:
Belonging.PLAYER:
shot_particles.process_material.emission_shape_offset.x = SHOT_OFFSET_X
shot_particles.process_material.direction = 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.UP
Belonging.ENEMY:
shot_particles.process_material.emission_shape_offset.x = -SHOT_OFFSET_X
shot_particles.process_material.direction = 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.DOWN
func _restart_particles() -> void:
shot_particles.restart()
shell_particles.restart()
@@ -104,9 +104,10 @@ animations = [{
resource_local_to_scene = true
particle_flag_disable_z = true
inherit_velocity_ratio = 1.0
direction = Vector3(0, 1, 0)
spread = 15.0
initial_velocity_min = 15.0
initial_velocity_max = 50.0
initial_velocity_max = 25.0
gravity = Vector3(0, 0, 0)
[node name="ShrapnelWeapon" instance=ExtResource("1_xk300")]
@@ -117,6 +118,7 @@ Projectile = ExtResource("2_xvd4y")
type = 0
[node name="ShotParticles" type="GPUParticles2D" parent="." index="0"]
position = Vector2(17, 0)
emitting = false
amount = 32
texture = ExtResource("4_0tw2i")
@@ -125,6 +127,7 @@ one_shot = true
process_material = SubResource("ParticleProcessMaterial_a22j7")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="1"]
position = Vector2(7, 0)
sprite_frames = SubResource("SpriteFrames_he4pe")
animation = &"player_shot"
@@ -134,6 +137,7 @@ one_shot = true
[node name="ShellParticles" type="GPUParticles2D" parent="." index="3"]
z_index = 1
position = Vector2(-1, 1)
emitting = false
amount = 1
texture = ExtResource("6_gdolk")
@@ -141,5 +145,8 @@ lifetime = 2.0
one_shot = true
process_material = SubResource("ParticleProcessMaterial_t57yr")
[node name="Muzzle" parent="." index="4"]
position = Vector2(14, 0)
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
[connection signal="timeout" from="CooldownTimer" to="." method="_on_cooldown_timer_timeout"]
+4 -10
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=3 uid="uid://dyebeblayioji"]
[gd_scene load_steps=24 format=3 uid="uid://dyebeblayioji"]
[ext_resource type="PackedScene" uid="uid://1o2ta17yc5bp" path="res://game/entities/weapons/abstract_weapon.tscn" id="1_rpud7"]
[ext_resource type="PackedScene" uid="uid://bi64687wtxi4d" path="res://game/entities/weapons/tesla/tesla_projectile.tscn" id="2_1rrdy"]
@@ -6,9 +6,6 @@
[ext_resource type="Texture2D" uid="uid://c6aixtu6lbfud" path="res://particle_textures/energy_small.tres" id="5_dhfvk"]
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="7_ub67s"]
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_dra6h"]
size = Vector2(10, 7)
[sub_resource type="AtlasTexture" id="AtlasTexture_ucdpq"]
atlas = ExtResource("7_ub67s")
region = Rect2(0, 16, 32, 16)
@@ -151,21 +148,18 @@ sector_angle = 10
Projectile = ExtResource("2_1rrdy")
type = 3
[node name="Sprite2D" type="Sprite2D" parent="." index="0"]
texture = SubResource("PlaceholderTexture2D_dra6h")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="1"]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0"]
sprite_frames = SubResource("SpriteFrames_ckvhw")
animation = &"player_idle"
[node name="GPUParticles2D" type="GPUParticles2D" parent="." index="2"]
[node name="GPUParticles2D" type="GPUParticles2D" parent="." index="1"]
amount = 16
texture = ExtResource("5_dhfvk")
lifetime = 0.1
fixed_fps = 10
process_material = SubResource("ParticleProcessMaterial_ifsj2")
[node name="CooldownTimer" type="Timer" parent="." index="3"]
[node name="CooldownTimer" type="Timer" parent="." index="2"]
wait_time = 1.3
one_shot = true