Added railgun textures

This commit is contained in:
2025-11-23 17:46:57 +03:00
parent 6c142dd695
commit a6185d7ce1
14 changed files with 241 additions and 74 deletions
-1
View File
@@ -3,7 +3,6 @@ extends Node
signal accelerate(direction: Vector2, delta: float)
signal shoot(weapon_index: int)
signal reload(weapon_index: int)
func _physics_process(delta: float) -> void:
+3 -8
View File
@@ -6,20 +6,15 @@ signal accelerate(direction: Vector2, delta: float)
signal shoot(weapon_index: int)
signal reload(weapon_index: int)
func _physics_process(delta: float) -> void:
var input_direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
accelerate.emit(input_direction, delta)
var weapon_actions := {
0: ["shoot_weapon_1", "reload_weapon_1"],
1: ["shoot_weapon_2", "reload_weapon_2"]
0: "shoot_weapon_1",
1: "shoot_weapon_2",
}
for index : int in weapon_actions:
if Input.is_action_pressed(weapon_actions[index][0]):
if Input.is_action_pressed(weapon_actions[index]):
shoot.emit(index)
if Input.is_action_pressed(weapon_actions[index][1]):
reload.emit(index)
-6
View File
@@ -81,12 +81,6 @@ func shoot(weapon_index: int) -> void:
_weapons[weapon_index].shoot(velocity)
func reload(weapon_index: int) -> void:
if weapon_index >= _weapons.size(): return
_weapons[weapon_index].reload()
func _get_new_speed(accel: float, decel: float, current_speed: float) -> float:
if is_zero_approx(accel):
if absf(current_speed) < decel:
@@ -38,5 +38,4 @@ offset_bottom = 22.0
[node name="PlayerController" parent="." index="4" instance=ExtResource("3_4mjo1")]
[connection signal="accelerate" from="PlayerController" to="." method="accelerate"]
[connection signal="reload" from="PlayerController" to="." method="reload"]
[connection signal="shoot" from="PlayerController" to="." method="shoot"]
+1 -5
View File
@@ -19,6 +19,7 @@ const PREFIXES := {
const SHOT_POSTFIX = "_shot"
const IDLE_POSTFIX = "_idle"
const RELOAD_POSTFIX = "_reloading"
var _belonging: Belonging
@@ -76,11 +77,6 @@ func _create_projectile(ship_velocity: Vector2) -> AbstractProjectile:
return projectile
func reload() -> void:
for reloader in reloaders:
reloader.reload()
func _reloaders_can_shoot() -> bool:
for reloader in reloaders:
if not reloader.can_shoot():
+10 -10
View File
@@ -45,43 +45,43 @@ gravity = Vector3(0, 0, 0)
[sub_resource type="AtlasTexture" id="AtlasTexture_jfd4t"]
atlas = ExtResource("6_jfd4t")
region = Rect2(0, 160, 32, 16)
region = Rect2(0, 176, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_i0ica"]
atlas = ExtResource("6_jfd4t")
region = Rect2(32, 160, 32, 16)
region = Rect2(32, 176, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_377p4"]
atlas = ExtResource("6_jfd4t")
region = Rect2(64, 160, 32, 16)
region = Rect2(64, 176, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_nrbut"]
atlas = ExtResource("6_jfd4t")
region = Rect2(96, 160, 32, 16)
region = Rect2(96, 176, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_mk6k8"]
atlas = ExtResource("6_jfd4t")
region = Rect2(128, 160, 32, 16)
region = Rect2(128, 176, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_fxfcx"]
atlas = ExtResource("6_jfd4t")
region = Rect2(0, 144, 32, 16)
region = Rect2(0, 160, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_dvc0n"]
atlas = ExtResource("6_jfd4t")
region = Rect2(32, 144, 32, 16)
region = Rect2(32, 160, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_caj01"]
atlas = ExtResource("6_jfd4t")
region = Rect2(64, 144, 32, 16)
region = Rect2(64, 160, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_e28g8"]
atlas = ExtResource("6_jfd4t")
region = Rect2(96, 144, 32, 16)
region = Rect2(96, 160, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_f7kmj"]
atlas = ExtResource("6_jfd4t")
region = Rect2(128, 144, 32, 16)
region = Rect2(128, 160, 32, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_kdf62"]
animations = [{
@@ -66,11 +66,11 @@ gravity = Vector3(0, 0, 0)
[sub_resource type="AtlasTexture" id="AtlasTexture_u8eh0"]
atlas = ExtResource("6_3cw5x")
region = Rect2(224, 112, 32, 16)
region = Rect2(224, 128, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ylgjm"]
atlas = ExtResource("6_3cw5x")
region = Rect2(224, 128, 32, 16)
region = Rect2(224, 144, 32, 16)
[node name="LauncherWeapon" instance=ExtResource("1_sk5u1")]
script = ExtResource("2_mxjpe")
@@ -7,51 +7,51 @@
[sub_resource type="AtlasTexture" id="AtlasTexture_ais8e"]
atlas = ExtResource("6_ais8e")
region = Rect2(0, 128, 32, 16)
region = Rect2(0, 144, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_a7h2a"]
atlas = ExtResource("6_ais8e")
region = Rect2(32, 128, 32, 16)
region = Rect2(32, 144, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_5u2pu"]
atlas = ExtResource("6_ais8e")
region = Rect2(64, 128, 32, 16)
region = Rect2(64, 144, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_iwxdg"]
atlas = ExtResource("6_ais8e")
region = Rect2(96, 128, 32, 16)
region = Rect2(96, 144, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_oyt37"]
atlas = ExtResource("6_ais8e")
region = Rect2(128, 128, 32, 16)
region = Rect2(128, 144, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_fvahc"]
atlas = ExtResource("6_ais8e")
region = Rect2(160, 128, 32, 16)
region = Rect2(160, 144, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_6718t"]
atlas = ExtResource("6_ais8e")
region = Rect2(0, 112, 32, 16)
region = Rect2(0, 128, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_wwpdh"]
atlas = ExtResource("6_ais8e")
region = Rect2(32, 112, 32, 16)
region = Rect2(32, 128, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_m6clj"]
atlas = ExtResource("6_ais8e")
region = Rect2(64, 112, 32, 16)
region = Rect2(64, 128, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_tqqar"]
atlas = ExtResource("6_ais8e")
region = Rect2(96, 112, 32, 16)
region = Rect2(96, 128, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_mq3tp"]
atlas = ExtResource("6_ais8e")
region = Rect2(128, 112, 32, 16)
region = Rect2(128, 128, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_8yhut"]
atlas = ExtResource("6_ais8e")
region = Rect2(160, 112, 32, 16)
region = Rect2(160, 128, 32, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_wwpdh"]
animations = [{
@@ -1,15 +1,31 @@
[gd_scene load_steps=9 format=3 uid="uid://bab3bopsw74cb"]
[gd_scene load_steps=11 format=3 uid="uid://bab3bopsw74cb"]
[ext_resource type="Script" uid="uid://n3h1e3pj02g0" path="res://game/entities/weapons/railgun/railgun_projectile.gd" id="1_hycpq"]
[ext_resource type="PackedScene" uid="uid://cdv5n4t47hr8i" path="res://game/entities/weapons/direct_hit__projectile.tscn" id="1_rfd1j"]
[ext_resource type="Script" uid="uid://bhqvk5cnjg5mv" path="res://game/health_system/damage/kinetic_damage.gd" id="3_wbdf3"]
[ext_resource type="Texture2D" uid="uid://oj86smpsipw4" path="res://images/projectiles.png" id="4_u82jm"]
[ext_resource type="Texture2D" uid="uid://dedca1d30igae" path="res://particle_textures/energy.tres" id="5_whmfh"]
[sub_resource type="Resource" id="Resource_u82jm"]
script = ExtResource("3_wbdf3")
value = 45
metadata/_custom_type_script = "uid://bhqvk5cnjg5mv"
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_yedu2"]
lifetime_randomness = 0.5
particle_flag_disable_z = true
emission_shape = 1
emission_sphere_radius = 2.0
angle_min = -179.99998
angle_max = 180.00002
inherit_velocity_ratio = 0.2
spread = 180.0
initial_velocity_max = 50.0
gravity = Vector3(0, 0, 0)
turbulence_enabled = true
turbulence_noise_strength = 2.0
turbulence_noise_speed_random = 1.0
[sub_resource type="AtlasTexture" id="AtlasTexture_u82jm"]
atlas = ExtResource("4_u82jm")
region = Rect2(32, 0, 16, 16)
@@ -30,11 +46,17 @@ piercing = 1
damage = SubResource("Resource_u82jm")
speed = 900
[node name="Sprite2D_Left" type="Sprite2D" parent="." index="0"]
[node name="GPUParticles2D" type="GPUParticles2D" parent="." index="0"]
amount = 32
texture = ExtResource("5_whmfh")
lifetime = 0.4
process_material = SubResource("ParticleProcessMaterial_yedu2")
[node name="Sprite2D_Left" type="Sprite2D" parent="." index="1"]
texture = SubResource("AtlasTexture_u82jm")
[node name="Sprite2D_Right" type="Sprite2D" parent="." index="1"]
[node name="Sprite2D_Right" type="Sprite2D" parent="." index="2"]
texture = SubResource("AtlasTexture_whmfh")
[node name="CollisionShape2D" parent="." index="2"]
[node name="CollisionShape2D" parent="." index="3"]
shape = SubResource("CapsuleShape2D_u82jm")
@@ -1 +1,31 @@
extends AbstractWeapon
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
func set_belonging(belonging: Belonging) -> void:
super.set_belonging(belonging)
sprite.play(PREFIXES[_belonging] + IDLE_POSTFIX)
func shoot(ship_velocity: Vector2) -> bool:
var is_shot := super.shoot(ship_velocity)
if is_shot:
sprite.play(PREFIXES[_belonging] + SHOT_POSTFIX)
print(1, sprite.animation)
_can_shoot = false
return is_shot
func _on_animated_sprite_2d_animation_finished() -> void:
if sprite.animation.ends_with(SHOT_POSTFIX):
sprite.play(PREFIXES[_belonging] + RELOAD_POSTFIX)
print(PREFIXES[_belonging] + RELOAD_POSTFIX)
print(2, sprite.animation)
else:
sprite.play(PREFIXES[_belonging] + IDLE_POSTFIX)
print(3, sprite.animation)
_can_shoot = true
@@ -1,23 +1,168 @@
[gd_scene load_steps=8 format=3 uid="uid://do6h77gmnreho"]
[gd_scene load_steps=23 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="Script" uid="uid://ccpriilfr3kme" path="res://game/reloaders/abstract_reloader.gd" id="3_qxka8"]
[ext_resource type="Script" uid="uid://b255rb32vc6co" path="res://game/reloaders/firerate_reloader.gd" id="4_igknv"]
[sub_resource type="Resource" id="Resource_5nhwg"]
script = ExtResource("4_igknv")
firerate = 60
metadata/_custom_type_script = "uid://b255rb32vc6co"
[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)
[sub_resource type="AtlasTexture" id="AtlasTexture_6uyey"]
atlas = ExtResource("4_qxcog")
region = Rect2(96, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_knads"]
atlas = ExtResource("4_qxcog")
region = Rect2(128, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jxlhs"]
atlas = ExtResource("4_qxcog")
region = Rect2(160, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_o0am2"]
atlas = ExtResource("4_qxcog")
region = Rect2(192, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_gxvdx"]
atlas = ExtResource("4_qxcog")
region = Rect2(224, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_caa1b"]
atlas = ExtResource("4_qxcog")
region = Rect2(32, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_dshqd"]
atlas = ExtResource("4_qxcog")
region = Rect2(64, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_12cl3"]
atlas = ExtResource("4_qxcog")
region = Rect2(0, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_q6uk7"]
atlas = ExtResource("4_qxcog")
region = Rect2(96, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ggjt2"]
atlas = ExtResource("4_qxcog")
region = Rect2(128, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jra8e"]
atlas = ExtResource("4_qxcog")
region = Rect2(160, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_hqd47"]
atlas = ExtResource("4_qxcog")
region = Rect2(192, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_hu0my"]
atlas = ExtResource("4_qxcog")
region = Rect2(224, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_kjbu2"]
atlas = ExtResource("4_qxcog")
region = Rect2(32, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_2g4rr"]
atlas = ExtResource("4_qxcog")
region = Rect2(64, 96, 32, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_caa1b"]
resource_local_to_scene = true
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qxcog")
}],
"loop": true,
"name": &"enemy_idle",
"speed": 10.0
}, {
"frames": [{
"duration": 6.0,
"texture": SubResource("AtlasTexture_6uyey")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_knads")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jxlhs")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_o0am2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gxvdx")
}],
"loop": false,
"name": &"enemy_reloading",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_caa1b")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dshqd")
}],
"loop": false,
"name": &"enemy_shot",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_12cl3")
}],
"loop": true,
"name": &"player_idle",
"speed": 10.0
}, {
"frames": [{
"duration": 6.0,
"texture": SubResource("AtlasTexture_q6uk7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ggjt2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jra8e")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hqd47")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hu0my")
}],
"loop": false,
"name": &"player_reloading",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_kjbu2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2g4rr")
}],
"loop": false,
"name": &"player_shot",
"speed": 10.0
}]
[node name="RailgunWeapon" instance=ExtResource("1_0nxvu")]
script = ExtResource("1_5nhwg")
Projectile = ExtResource("2_cbsia")
reloaders = Array[ExtResource("3_qxka8")]([SubResource("Resource_5nhwg")])
[node name="Sprite2D" type="Sprite2D" parent="." index="0"]
texture = SubResource("PlaceholderTexture2D_dra6h")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="1"]
sprite_frames = SubResource("SpriteFrames_caa1b")
animation = &"enemy_reloading"
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
BIN
View File
Binary file not shown.
+1
View File
@@ -7,6 +7,7 @@ extends Control
func _ready() -> void:
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
_show_menu(main_menu)
-14
View File
@@ -312,20 +312,6 @@ shoot_weapon_2={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":true,"script":null)
]
}
reload_weapon_1={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":49,"key_label":0,"unicode":49,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194442,"key_label":0,"unicode":52,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":true,"script":null)
]
}
reload_weapon_2={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":50,"key_label":0,"unicode":50,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194443,"key_label":0,"unicode":53,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":true,"script":null)
]
}
blink={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"location":1,"echo":false,"script":null)