Added blinks
This commit is contained in:
@@ -2,6 +2,13 @@ class_name PlayerShip
|
||||
extends AbstractShip
|
||||
|
||||
|
||||
@export_range(0, 200) var blink_range := 0
|
||||
|
||||
|
||||
@onready var blink_timer : Timer = $BlinkTimer
|
||||
@onready var blink_shadow : GPUParticles2D = $BlinkShadow
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
for weapon in _weapons:
|
||||
@@ -12,3 +19,20 @@ func _on_player_controller_shoot(weapon_index: int) -> void:
|
||||
if weapon_index >= _weapons.size(): return
|
||||
|
||||
_weapons[weapon_index].shoot(velocity)
|
||||
|
||||
|
||||
func _blink(direction: Vector2) -> void:
|
||||
if not blink_timer.is_stopped(): return
|
||||
|
||||
blink_timer.start()
|
||||
|
||||
var shadow : GPUParticles2D = blink_shadow.duplicate()
|
||||
var process_material : ParticleProcessMaterial = shadow.process_material
|
||||
process_material.direction = Vector3(direction.x, direction.y, 0)
|
||||
|
||||
shadow.emitting = true
|
||||
shadow.global_position = global_position
|
||||
get_tree().current_scene.add_child(shadow)
|
||||
shadow.finished.connect(shadow.queue_free)
|
||||
|
||||
move_and_collide(direction * blink_range)
|
||||
|
||||
@@ -1,21 +1,37 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://br074cqcnul3d"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://br074cqcnul3d"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://jvyagshykmgb" path="res://game/entities/ships/abstract_ship.tscn" id="1_6otxb"]
|
||||
[ext_resource type="Script" uid="uid://ruxw1n03iq4i" path="res://game/entities/ships/player/player_ship.gd" id="2_625ti"]
|
||||
[ext_resource type="PackedScene" uid="uid://dh1oj1w5wx4je" path="res://game/controllers/player_controller.tscn" id="3_4mjo1"]
|
||||
[ext_resource type="Texture2D" uid="uid://y2yfli24n51v" path="res://images/ships/player.png" id="3_uf2n1"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4mjo1"]
|
||||
atlas = ExtResource("3_uf2n1")
|
||||
region = Rect2(0, 0, 48, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_34rhw"]
|
||||
atlas = ExtResource("3_uf2n1")
|
||||
region = Rect2(0, 32, 48, 32)
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_pjmi2"]
|
||||
particle_flag_disable_z = true
|
||||
spread = 0.0
|
||||
initial_velocity_min = 500.0
|
||||
initial_velocity_max = 500.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
|
||||
[node name="PlayerShip" groups=["players"] instance=ExtResource("1_6otxb")]
|
||||
collision_layer = 3
|
||||
collision_mask = 5
|
||||
script = ExtResource("2_625ti")
|
||||
blink_range = 75
|
||||
acceleration = 92
|
||||
deceleration = 46
|
||||
max_speed = 92
|
||||
mass = 250
|
||||
|
||||
[node name="Sprite2D" parent="." index="0"]
|
||||
texture = ExtResource("3_uf2n1")
|
||||
texture = SubResource("AtlasTexture_4mjo1")
|
||||
|
||||
[node name="CollisionPolygon2D" parent="." index="1"]
|
||||
polygon = PackedVector2Array(-23, -10, -17, -14, -3, -15, 21, -13, 22, -12, 22, 12, 21, 13, -3, 15, -17, 14, -23, 10)
|
||||
@@ -36,5 +52,19 @@ position = Vector2(-2, 8)
|
||||
[node name="Second" type="Node2D" parent="WeaponSlots" index="1"]
|
||||
position = Vector2(-2, -8)
|
||||
|
||||
[node name="BlinkTimer" type="Timer" parent="." index="6"]
|
||||
process_callback = 0
|
||||
wait_time = 3.0
|
||||
one_shot = true
|
||||
|
||||
[node name="BlinkShadow" type="GPUParticles2D" parent="." index="7"]
|
||||
emitting = false
|
||||
amount = 2
|
||||
texture = SubResource("AtlasTexture_34rhw")
|
||||
lifetime = 0.09999999999999999
|
||||
one_shot = true
|
||||
process_material = SubResource("ParticleProcessMaterial_pjmi2")
|
||||
|
||||
[connection signal="accelerate" from="PlayerController" to="." method="accelerate"]
|
||||
[connection signal="blink" from="PlayerController" to="." method="_blink"]
|
||||
[connection signal="shoot" from="PlayerController" to="." method="_on_player_controller_shoot"]
|
||||
|
||||
Reference in New Issue
Block a user