Added blinks
This commit is contained in:
@@ -6,6 +6,8 @@ signal accelerate(direction: Vector2, delta: float)
|
|||||||
|
|
||||||
signal shoot(weapon_index: int)
|
signal shoot(weapon_index: int)
|
||||||
|
|
||||||
|
signal blink(direction: Vector2)
|
||||||
|
|
||||||
|
|
||||||
const WEAPON_ACTIONS := {
|
const WEAPON_ACTIONS := {
|
||||||
0: "shoot_weapon_1",
|
0: "shoot_weapon_1",
|
||||||
@@ -14,9 +16,18 @@ const WEAPON_ACTIONS := {
|
|||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
var input_direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
var input_direction := _get_input_direction()
|
||||||
accelerate.emit(input_direction, delta)
|
accelerate.emit(input_direction, delta)
|
||||||
|
|
||||||
for index : int in WEAPON_ACTIONS:
|
for index : int in WEAPON_ACTIONS:
|
||||||
if Input.is_action_pressed(WEAPON_ACTIONS[index]):
|
if Input.is_action_pressed(WEAPON_ACTIONS[index]):
|
||||||
shoot.emit(index)
|
shoot.emit(index)
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if event.is_action_pressed("blink"):
|
||||||
|
var input_direction := _get_input_direction()
|
||||||
|
blink.emit(input_direction)
|
||||||
|
|
||||||
|
func _get_input_direction() -> Vector2:
|
||||||
|
return Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||||
|
|||||||
@@ -2,6 +2,13 @@ class_name PlayerShip
|
|||||||
extends AbstractShip
|
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:
|
func _ready() -> void:
|
||||||
super._ready()
|
super._ready()
|
||||||
for weapon in _weapons:
|
for weapon in _weapons:
|
||||||
@@ -12,3 +19,20 @@ func _on_player_controller_shoot(weapon_index: int) -> void:
|
|||||||
if weapon_index >= _weapons.size(): return
|
if weapon_index >= _weapons.size(): return
|
||||||
|
|
||||||
_weapons[weapon_index].shoot(velocity)
|
_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="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="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="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"]
|
[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")]
|
[node name="PlayerShip" groups=["players"] instance=ExtResource("1_6otxb")]
|
||||||
collision_layer = 3
|
collision_layer = 3
|
||||||
collision_mask = 5
|
collision_mask = 5
|
||||||
script = ExtResource("2_625ti")
|
script = ExtResource("2_625ti")
|
||||||
|
blink_range = 75
|
||||||
acceleration = 92
|
acceleration = 92
|
||||||
deceleration = 46
|
deceleration = 46
|
||||||
max_speed = 92
|
max_speed = 92
|
||||||
mass = 250
|
mass = 250
|
||||||
|
|
||||||
[node name="Sprite2D" parent="." index="0"]
|
[node name="Sprite2D" parent="." index="0"]
|
||||||
texture = ExtResource("3_uf2n1")
|
texture = SubResource("AtlasTexture_4mjo1")
|
||||||
|
|
||||||
[node name="CollisionPolygon2D" parent="." index="1"]
|
[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)
|
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"]
|
[node name="Second" type="Node2D" parent="WeaponSlots" index="1"]
|
||||||
position = Vector2(-2, -8)
|
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="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"]
|
[connection signal="shoot" from="PlayerController" to="." method="_on_player_controller_shoot"]
|
||||||
|
|||||||
BIN
Binary file not shown.
@@ -27,11 +27,13 @@ layout_mode = 2
|
|||||||
columns = 2
|
columns = 2
|
||||||
|
|
||||||
[node name="ProgrammingLabel" type="Label" parent="VBoxContainer/GridContainer"]
|
[node name="ProgrammingLabel" type="Label" parent="VBoxContainer/GridContainer"]
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Programming:"
|
text = "Programming:"
|
||||||
horizontal_alignment = 2
|
horizontal_alignment = 2
|
||||||
|
|
||||||
[node name="ProgrammersLabel" type="Label" parent="VBoxContainer/GridContainer"]
|
[node name="ProgrammersLabel" type="Label" parent="VBoxContainer/GridContainer"]
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Ruslan Ignatov"
|
text = "Ruslan Ignatov"
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@ alignment = 2
|
|||||||
|
|
||||||
[node name="BackButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
[node name="BackButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
theme = ExtResource("2_nidem")
|
theme = ExtResource("2_nidem")
|
||||||
|
|||||||
@@ -24,19 +24,21 @@ grow_vertical = 2
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer"]
|
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer"]
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Game Over"
|
text = "Game Over"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="MainMenuButton" type="Button" parent="CenterContainer/VBoxContainer"]
|
[node name="MainMenuButton" type="Button" parent="CenterContainer/VBoxContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
theme = ExtResource("2_uh3ar")
|
theme = ExtResource("2_uh3ar")
|
||||||
text = "Main Menu"
|
text = "Main Menu"
|
||||||
|
|
||||||
[node name="ButtonFocusTimer" type="Timer" parent="."]
|
[node name="ButtonFocusTimer" type="Timer" parent="."]
|
||||||
wait_time = 3.0
|
wait_time = 1.5
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
||||||
|
|||||||
@@ -29,21 +29,25 @@ columns = 2
|
|||||||
|
|
||||||
[node name="FullscreenLabel" type="Label" parent="VBoxContainer/OptionsGridContainer"]
|
[node name="FullscreenLabel" type="Label" parent="VBoxContainer/OptionsGridContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Fullscreen"
|
text = "Fullscreen"
|
||||||
|
|
||||||
[node name="FullscreenCheckButton" type="CheckButton" parent="VBoxContainer/OptionsGridContainer"]
|
[node name="FullscreenCheckButton" type="CheckButton" parent="VBoxContainer/OptionsGridContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
|
|
||||||
[node name="WindowFactorLabel" type="Label" parent="VBoxContainer/OptionsGridContainer"]
|
[node name="WindowFactorLabel" type="Label" parent="VBoxContainer/OptionsGridContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Window Factor"
|
text = "Window Factor"
|
||||||
|
|
||||||
[node name="WindowFactorOptionButton" type="OptionButton" parent="VBoxContainer/OptionsGridContainer"]
|
[node name="WindowFactorOptionButton" type="OptionButton" parent="VBoxContainer/OptionsGridContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
selected = 0
|
selected = 0
|
||||||
@@ -67,6 +71,7 @@ alignment = 2
|
|||||||
|
|
||||||
[node name="CreditsButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
[node name="CreditsButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
theme = ExtResource("2_1tdpy")
|
theme = ExtResource("2_1tdpy")
|
||||||
@@ -74,6 +79,7 @@ text = "Credits"
|
|||||||
|
|
||||||
[node name="BackButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
[node name="BackButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
theme = ExtResource("2_1tdpy")
|
theme = ExtResource("2_1tdpy")
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ offset_bottom = 166.0
|
|||||||
|
|
||||||
[node name="ContinueButton" type="Button" parent="VBoxContainer"]
|
[node name="ContinueButton" type="Button" parent="VBoxContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
theme = ExtResource("2_vy7sn")
|
theme = ExtResource("2_vy7sn")
|
||||||
@@ -28,6 +29,7 @@ shortcut = SubResource("Shortcut_lgp46")
|
|||||||
text = "CONTINUE"
|
text = "CONTINUE"
|
||||||
|
|
||||||
[node name="OptionsButton" type="Button" parent="VBoxContainer"]
|
[node name="OptionsButton" type="Button" parent="VBoxContainer"]
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
theme = ExtResource("2_vy7sn")
|
theme = ExtResource("2_vy7sn")
|
||||||
@@ -35,6 +37,7 @@ text = "OPTIONS"
|
|||||||
|
|
||||||
[node name="MainMenuButton" type="Button" parent="VBoxContainer"]
|
[node name="MainMenuButton" type="Button" parent="VBoxContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
z_index = 100
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
theme = ExtResource("2_vy7sn")
|
theme = ExtResource("2_vy7sn")
|
||||||
|
|||||||
Reference in New Issue
Block a user