Compare commits
10 commits
main
...
signal-ref
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ef6076eda | ||
|
|
485f03d702 | ||
|
|
a73fb28552 | ||
|
|
afc5c68569 | ||
|
|
9f2569a73c | ||
|
|
65a887e9db | ||
|
|
d739beb6f2 | ||
|
|
1ebba28e5d | ||
|
|
d64504189a | ||
|
|
ab8643d093 |
14 changed files with 174 additions and 107 deletions
5
enemy.gd
5
enemy.gd
|
|
@ -1,7 +1,5 @@
|
||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
signal died
|
|
||||||
|
|
||||||
var bullet_scene = preload("res://enemy_bullet.tscn")
|
var bullet_scene = preload("res://enemy_bullet.tscn")
|
||||||
var start_pos = Vector2.ZERO
|
var start_pos = Vector2.ZERO
|
||||||
var speed = 0
|
var speed = 0
|
||||||
|
|
@ -38,9 +36,10 @@ func _process(delta):
|
||||||
|
|
||||||
|
|
||||||
func explode():
|
func explode():
|
||||||
|
print_debug("Enemy explode!")
|
||||||
speed = 0
|
speed = 0
|
||||||
$AnimationPlayer.play("explode")
|
$AnimationPlayer.play("explode")
|
||||||
set_deferred("monitoring", false)
|
set_deferred("monitoring", false)
|
||||||
died.emit(5)
|
EventBus.enemy_died.emit(5)
|
||||||
await $AnimationPlayer.animation_finished
|
await $AnimationPlayer.animation_finished
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
|
||||||
9
event_bus.gd
Normal file
9
event_bus.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@warning_ignore_start("unused_signal") # since otherwise Godot will throw a warning that the signal is unused in current scope
|
||||||
|
|
||||||
|
signal shield_changed(max_value: int, old_value: int, new_value: int)
|
||||||
|
signal player_died()
|
||||||
|
signal enemy_died(value: int)
|
||||||
|
|
||||||
|
@warning_ignore_restore("unused_signal") # put any future signals you add between the two ignore annotations
|
||||||
1
event_bus.gd.uid
Normal file
1
event_bus.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://jibpipn2p1c7
|
||||||
|
|
@ -2,6 +2,21 @@
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://h04wm5a27u0" path="res://Mini Pixel Pack 3/Effects/Explosion (16 x 16).png" id="1_q7epf"]
|
[ext_resource type="Texture2D" uid="uid://h04wm5a27u0" path="res://Mini Pixel Pack 3/Effects/Explosion (16 x 16).png" id="1_q7epf"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_j4sxf"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_vxas0"]
|
[sub_resource type="Animation" id="Animation_vxas0"]
|
||||||
resource_name = "explosion-one-shot"
|
resource_name = "explosion-one-shot"
|
||||||
length = 0.5
|
length = 0.5
|
||||||
|
|
@ -19,21 +34,6 @@ tracks/0/keys = {
|
||||||
"values": [0, 1, 3, 4, 5]
|
"values": [0, 1, 3, 4, 5]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_j4sxf"]
|
|
||||||
length = 0.001
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath(".:frame")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 1,
|
|
||||||
"values": [0]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_m5xho"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_m5xho"]
|
||||||
_data = {
|
_data = {
|
||||||
&"RESET": SubResource("Animation_j4sxf"),
|
&"RESET": SubResource("Animation_j4sxf"),
|
||||||
|
|
@ -48,4 +48,4 @@ hframes = 6
|
||||||
libraries = {
|
libraries = {
|
||||||
&"": SubResource("AnimationLibrary_m5xho")
|
&"": SubResource("AnimationLibrary_m5xho")
|
||||||
}
|
}
|
||||||
autoplay = "explosion-one-shot"
|
autoplay = "RESET"
|
||||||
|
|
|
||||||
45
main.gd
45
main.gd
|
|
@ -1,42 +1,63 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
var enemy = preload("res://enemy.tscn")
|
||||||
|
var score = 0
|
||||||
|
var playing = false
|
||||||
|
var enemy_count: int = 0
|
||||||
|
|
||||||
@onready var start_button = $CanvasLayer/CenterContainer/Start
|
@onready var start_button = $CanvasLayer/CenterContainer/Start
|
||||||
@onready var game_over = $CanvasLayer/CenterContainer/GameOver
|
@onready var game_over = $CanvasLayer/CenterContainer/GameOver
|
||||||
|
|
||||||
var enemy = preload("res://enemy.tscn")
|
|
||||||
var score = 0
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
start_button.show()
|
|
||||||
game_over.hide()
|
game_over.hide()
|
||||||
|
start_button.show()
|
||||||
|
EventBus.player_died.connect(_on_player_died)
|
||||||
|
EventBus.enemy_died.connect(_on_enemy_died)
|
||||||
# spawn_enemies()
|
# spawn_enemies()
|
||||||
|
|
||||||
func new_game():
|
|
||||||
score = 0
|
|
||||||
$CanvasLayer/UI.update_score(score)
|
|
||||||
$Player.start()
|
|
||||||
spawn_enemies()
|
|
||||||
|
|
||||||
func spawn_enemies():
|
func spawn_enemies():
|
||||||
|
|
||||||
for x in range(9):
|
for x in range(9):
|
||||||
for y in range(3):
|
for y in range(3):
|
||||||
var e = enemy.instantiate()
|
var e = enemy.instantiate()
|
||||||
var pos = Vector2(x * (16 + 8) + 24, 16 * 4 + y * 16)
|
var pos = Vector2(x * (16 + 8) + 24, 16 * 4 + y * 16)
|
||||||
add_child(e)
|
add_child(e)
|
||||||
e.start(pos)
|
e.start(pos)
|
||||||
e.died.connect(_on_enemy_died)
|
enemy_count = get_tree().get_nodes_in_group("enemies").size()
|
||||||
|
print(enemy_count)
|
||||||
|
|
||||||
func _on_enemy_died(value):
|
|
||||||
|
func _on_enemy_died(value: int):
|
||||||
score += value
|
score += value
|
||||||
|
enemy_count -= 1
|
||||||
$CanvasLayer/UI.update_score(score)
|
$CanvasLayer/UI.update_score(score)
|
||||||
|
print_debug(enemy_count)
|
||||||
|
if enemy_count == 0:
|
||||||
|
print("All enemies defeated!")
|
||||||
|
win_game()
|
||||||
|
|
||||||
func _on_player_died():
|
func _on_player_died():
|
||||||
|
playing = false
|
||||||
get_tree().call_group("enemies", "queue_free")
|
get_tree().call_group("enemies", "queue_free")
|
||||||
game_over.show()
|
game_over.show()
|
||||||
await get_tree().create_timer(2).timeout
|
await get_tree().create_timer(2).timeout
|
||||||
game_over.hide()
|
game_over.hide()
|
||||||
start_button.show()
|
start_button.show()
|
||||||
|
|
||||||
|
func new_game():
|
||||||
|
score = 0
|
||||||
|
$CanvasLayer/UI.update_score(score)
|
||||||
|
$Player.start()
|
||||||
|
spawn_enemies()
|
||||||
|
playing = true
|
||||||
|
|
||||||
func _on_start_pressed():
|
func _on_start_pressed():
|
||||||
start_button.hide()
|
start_button.hide()
|
||||||
new_game()
|
new_game()
|
||||||
|
|
||||||
|
func win_game():
|
||||||
|
playing = false
|
||||||
|
game_over.show()
|
||||||
|
await get_tree().create_timer(2).timeout
|
||||||
|
game_over.hide()
|
||||||
|
start_button.show()
|
||||||
|
|
|
||||||
39
main.tscn
39
main.tscn
|
|
@ -1,9 +1,8 @@
|
||||||
[gd_scene load_steps=13 format=3 uid="uid://cc2dnhuv4qx7m"]
|
[gd_scene load_steps=11 format=3 uid="uid://cc2dnhuv4qx7m"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c51huloycn5as" path="res://main.gd" id="1_h2yge"]
|
[ext_resource type="Script" uid="uid://c51huloycn5as" path="res://main.gd" id="1_h2yge"]
|
||||||
[ext_resource type="Texture2D" uid="uid://jj8b7vqj3ihx" path="res://Mini Pixel Pack 3/Space_BG (2 frames) (64 x 64).png" id="1_ig7tw"]
|
[ext_resource type="Texture2D" uid="uid://jj8b7vqj3ihx" path="res://Mini Pixel Pack 3/Space_BG (2 frames) (64 x 64).png" id="1_ig7tw"]
|
||||||
[ext_resource type="PackedScene" uid="uid://pyuorpwb7lpe" path="res://player.tscn" id="2_0xm2m"]
|
[ext_resource type="PackedScene" uid="uid://pyuorpwb7lpe" path="res://player.tscn" id="2_0xm2m"]
|
||||||
[ext_resource type="Shader" uid="uid://c4jtlpwspb778" path="res://crt.gdshader" id="3_272bh"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://s6wf3egdqtmh" path="res://ui.tscn" id="4_1bvp3"]
|
[ext_resource type="PackedScene" uid="uid://s6wf3egdqtmh" path="res://ui.tscn" id="4_1bvp3"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bonoqs5pisflo" path="res://Mini Pixel Pack 3/UI objects/START (48 x 8).png" id="5_lquwl"]
|
[ext_resource type="Texture2D" uid="uid://bonoqs5pisflo" path="res://Mini Pixel Pack 3/UI objects/START (48 x 8).png" id="5_lquwl"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bubqwoum50gf8" path="res://Mini Pixel Pack 3/UI objects/GAME_OVER (72 x 8).png" id="6_7mycd"]
|
[ext_resource type="Texture2D" uid="uid://bubqwoum50gf8" path="res://Mini Pixel Pack 3/UI objects/GAME_OVER (72 x 8).png" id="6_7mycd"]
|
||||||
|
|
@ -48,30 +47,6 @@ _data = {
|
||||||
&"scroll": SubResource("Animation_h2yge")
|
&"scroll": SubResource("Animation_h2yge")
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kek77"]
|
|
||||||
shader = ExtResource("3_272bh")
|
|
||||||
shader_parameter/overlay = true
|
|
||||||
shader_parameter/resolution = Vector2(640, 480)
|
|
||||||
shader_parameter/brightness = 1.4
|
|
||||||
shader_parameter/scanlines_opacity = 0.530000025175
|
|
||||||
shader_parameter/scanlines_width = 0.2370000112575
|
|
||||||
shader_parameter/grille_opacity = 0.3
|
|
||||||
shader_parameter/roll = false
|
|
||||||
shader_parameter/roll_speed = 4.0
|
|
||||||
shader_parameter/roll_size = 5.0000002375
|
|
||||||
shader_parameter/roll_variation = 0.90200003958512
|
|
||||||
shader_parameter/distort_intensity = 0.0
|
|
||||||
shader_parameter/aberration = 0.03
|
|
||||||
shader_parameter/noise_opacity = 0.4
|
|
||||||
shader_parameter/noise_speed = 5.0
|
|
||||||
shader_parameter/static_noise_intensity = 0.06
|
|
||||||
shader_parameter/pixelate = true
|
|
||||||
shader_parameter/discolor = true
|
|
||||||
shader_parameter/warp_amount = 0.0
|
|
||||||
shader_parameter/clip_warp = false
|
|
||||||
shader_parameter/vignette_intensity = 0.4
|
|
||||||
shader_parameter/vignette_opacity = 0.1750000083125
|
|
||||||
|
|
||||||
[node name="Main" type="Node2D"]
|
[node name="Main" type="Node2D"]
|
||||||
script = ExtResource("1_h2yge")
|
script = ExtResource("1_h2yge")
|
||||||
|
|
||||||
|
|
@ -85,7 +60,7 @@ region_enabled = true
|
||||||
region_rect = Rect2(0, 0, 240, 320)
|
region_rect = Rect2(0, 0, 240, 320)
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("2_0xm2m")]
|
[node name="Player" parent="." instance=ExtResource("2_0xm2m")]
|
||||||
position = Vector2(123, 270)
|
position = Vector2(123, 272)
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
libraries = {
|
libraries = {
|
||||||
|
|
@ -96,6 +71,8 @@ autoplay = "scroll"
|
||||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="UI" parent="CanvasLayer" instance=ExtResource("4_1bvp3")]
|
[node name="UI" parent="CanvasLayer" instance=ExtResource("4_1bvp3")]
|
||||||
|
offset_right = 196.0
|
||||||
|
offset_bottom = 36.0
|
||||||
|
|
||||||
[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer"]
|
[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer"]
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
|
@ -112,12 +89,4 @@ texture_normal = ExtResource("5_lquwl")
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
texture = ExtResource("6_7mycd")
|
texture = ExtResource("6_7mycd")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
|
||||||
material = SubResource("ShaderMaterial_kek77")
|
|
||||||
position = Vector2(120, 161.5)
|
|
||||||
scale = Vector2(1.859375, 5.015625)
|
|
||||||
texture = ExtResource("1_ig7tw")
|
|
||||||
|
|
||||||
[connection signal="died" from="Player" to="." method="_on_player_died"]
|
|
||||||
[connection signal="shield_changed" from="Player" to="CanvasLayer/UI" method="update_shield"]
|
|
||||||
[connection signal="pressed" from="CanvasLayer/CenterContainer/Start" to="." method="_on_start_pressed"]
|
[connection signal="pressed" from="CanvasLayer/CenterContainer/Start" to="." method="_on_start_pressed"]
|
||||||
|
|
|
||||||
78
player.gd
78
player.gd
|
|
@ -1,19 +1,24 @@
|
||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
signal died
|
|
||||||
signal shield_changed
|
|
||||||
signal damage_taken
|
|
||||||
|
|
||||||
|
signal damage_taken
|
||||||
|
# signal shield_damage
|
||||||
|
# signal shield_ui
|
||||||
|
|
||||||
|
@export var speed: int = 150
|
||||||
|
@export var cooldown: float = 0.25
|
||||||
|
@export var bullet_scene : PackedScene
|
||||||
|
@export var max_shield: int = 10
|
||||||
|
var shield: int = max_shield:
|
||||||
|
set = set_shield
|
||||||
|
|
||||||
|
var can_shoot = true
|
||||||
var shader_active = false
|
var shader_active = false
|
||||||
|
|
||||||
@onready var screensize = get_viewport_rect().size
|
@onready var screensize = get_viewport_rect().size
|
||||||
@export var max_shield = 10
|
@onready var explosion = $Explosion
|
||||||
var shield = max_shield:
|
@onready var wait_time = $GunCooldown
|
||||||
set = set_shield
|
@onready var ship = $Ship
|
||||||
@export var speed = 150
|
|
||||||
@export var cooldown = 0.25
|
|
||||||
@export var bullet_scene : PackedScene
|
|
||||||
var can_shoot = true
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
start()
|
start()
|
||||||
|
|
@ -21,30 +26,10 @@ func _ready():
|
||||||
func start():
|
func start():
|
||||||
set_process(true)
|
set_process(true)
|
||||||
$Ship.show()
|
$Ship.show()
|
||||||
shield = max_shield
|
|
||||||
position = Vector2(screensize.x / 2, screensize.y - 64)
|
position = Vector2(screensize.x / 2, screensize.y - 64)
|
||||||
|
shield = max_shield
|
||||||
$GunCooldown.wait_time = cooldown
|
$GunCooldown.wait_time = cooldown
|
||||||
|
|
||||||
func set_shield(value):
|
|
||||||
shield = min(max_shield, value)
|
|
||||||
shield_changed.emit(max_shield, shield)
|
|
||||||
if shield <= 0:
|
|
||||||
set_process(false)
|
|
||||||
$Ship.hide()
|
|
||||||
$Explosion.show()
|
|
||||||
$Explosion/AnimationPlayer.play("explosion-one-shot")
|
|
||||||
await $Explosion/AnimationPlayer.animation_finished
|
|
||||||
died.emit()
|
|
||||||
|
|
||||||
func shoot():
|
|
||||||
if not can_shoot:
|
|
||||||
return
|
|
||||||
can_shoot = false
|
|
||||||
$GunCooldown.start()
|
|
||||||
var b = bullet_scene.instantiate()
|
|
||||||
get_tree().root.add_child(b)
|
|
||||||
b.start(position + Vector2(0, -8))
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
var input = Input.get_vector("left", "right", "up", "down")
|
var input = Input.get_vector("left", "right", "up", "down")
|
||||||
if input.x > 0:
|
if input.x > 0:
|
||||||
|
|
@ -61,22 +46,45 @@ func _process(delta):
|
||||||
if Input.is_action_pressed("shoot"):
|
if Input.is_action_pressed("shoot"):
|
||||||
shoot()
|
shoot()
|
||||||
|
|
||||||
func _on_gun_cooldown_timeout():
|
func shoot():
|
||||||
can_shoot = true
|
if not can_shoot:
|
||||||
|
return
|
||||||
|
can_shoot = false
|
||||||
|
$GunCooldown.start()
|
||||||
|
var b = bullet_scene.instantiate()
|
||||||
|
get_tree().root.add_child(b)
|
||||||
|
b.start(position + Vector2(0, -8))
|
||||||
|
var tween = create_tween().set_parallel(false)
|
||||||
|
tween.tween_property($Ship, "position:y", 1, 0.1)
|
||||||
|
tween.tween_property($Ship, "position:y", 0, 0.05)
|
||||||
|
|
||||||
func _on_gun_cool_down_timeout() -> void:
|
func set_shield(value: int):
|
||||||
|
var old_value: int = shield
|
||||||
|
shield = min(max_shield, value)
|
||||||
|
EventBus.shield_changed.emit(max_shield, old_value, shield)
|
||||||
|
print("Shield set to:", shield)
|
||||||
|
if shield <= 0:
|
||||||
|
set_process(false)
|
||||||
|
$Ship.hide()
|
||||||
|
$Explosion.show()
|
||||||
|
$Explosion/AnimationPlayer.play("explosion-one-shot")
|
||||||
|
await $Explosion/AnimationPlayer.animation_finished
|
||||||
|
EventBus.player_died.emit()
|
||||||
|
|
||||||
|
func _on_gun_cooldown_timeout() -> void:
|
||||||
can_shoot = true
|
can_shoot = true
|
||||||
|
|
||||||
func _on_area_entered(area):
|
func _on_area_entered(area):
|
||||||
if area.is_in_group("enemies"):
|
if area.is_in_group("enemies"):
|
||||||
area.explode()
|
area.explode()
|
||||||
shield -= max_shield / 2
|
shield -= int(max_shield / 2)
|
||||||
damage_taken.emit()
|
damage_taken.emit()
|
||||||
if area.is_in_group("enemy_bullets"):
|
if area.is_in_group("enemy_bullets"):
|
||||||
damage_taken.emit()
|
damage_taken.emit()
|
||||||
|
|
||||||
|
|
||||||
func _on_damage_taken() -> void:
|
func _on_damage_taken() -> void:
|
||||||
|
# emit_signal("shield_ui")
|
||||||
shader_active = true
|
shader_active = true
|
||||||
$Ship.material.set_shader_parameter("toggle", 1.0)
|
$Ship.material.set_shader_parameter("toggle", 1.0)
|
||||||
await get_tree().create_timer(1).timeout
|
await get_tree().create_timer(1).timeout
|
||||||
|
|
|
||||||
|
|
@ -104,4 +104,4 @@ visible = false
|
||||||
|
|
||||||
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
||||||
[connection signal="damage_taken" from="." to="." method="_on_damage_taken"]
|
[connection signal="damage_taken" from="." to="." method="_on_damage_taken"]
|
||||||
[connection signal="timeout" from="GunCooldown" to="." method="_on_gun_cool_down_timeout"]
|
[connection signal="timeout" from="GunCooldown" to="." method="_on_gun_cooldown_timeout"]
|
||||||
|
|
|
||||||
6
progress_bar.gd
Normal file
6
progress_bar.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
extends TextureProgressBar
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
self.value = 0
|
||||||
|
var shield_tween = get_tree().create_tween()
|
||||||
|
shield_tween.tween_property(self, "value", 100, 3).set_trans(Tween.TRANS_LINEAR)
|
||||||
1
progress_bar.gd.uid
Normal file
1
progress_bar.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://b85ktxeoj4b2n
|
||||||
19
progress_bar.tscn
Normal file
19
progress_bar.tscn
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://c8s7htpdg4v4i"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d11molrkdjjh5" path="res://bar_background.png" id="1_q0tf5"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bsl3pxvxiuoqg" path="res://bar_foreground.png" id="2_5xu4y"]
|
||||||
|
[ext_resource type="Script" uid="uid://b85ktxeoj4b2n" path="res://progress_bar.gd" id="3_5xu4y"]
|
||||||
|
|
||||||
|
[node name="ProgressBar" type="TextureProgressBar"]
|
||||||
|
anchors_preset = 10
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_bottom = 20.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
nine_patch_stretch = true
|
||||||
|
stretch_margin_left = 8
|
||||||
|
stretch_margin_top = 8
|
||||||
|
stretch_margin_right = 8
|
||||||
|
stretch_margin_bottom = 8
|
||||||
|
texture_under = ExtResource("1_q0tf5")
|
||||||
|
texture_progress = ExtResource("2_5xu4y")
|
||||||
|
script = ExtResource("3_5xu4y")
|
||||||
|
|
@ -14,6 +14,10 @@ config/name="shmup01b"
|
||||||
config/features=PackedStringArray("4.5", "Forward Plus")
|
config/features=PackedStringArray("4.5", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
EventBus="*res://event_bus.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/viewport_width=240
|
window/size/viewport_width=240
|
||||||
|
|
|
||||||
24
ui.gd
24
ui.gd
|
|
@ -3,10 +3,30 @@ extends MarginContainer
|
||||||
@onready var shield_bar = $HBoxContainer/ShieldBar
|
@onready var shield_bar = $HBoxContainer/ShieldBar
|
||||||
@onready var score_counter = $HBoxContainer/ScoreCounter
|
@onready var score_counter = $HBoxContainer/ScoreCounter
|
||||||
|
|
||||||
|
var shader_active = false
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# get_node("Player.Ship").node_ready.connect("shield_ui", self, "_on_shield_ui")
|
||||||
|
EventBus.shield_changed.connect(_on_shield_changed)
|
||||||
|
|
||||||
func update_score(value):
|
func update_score(value):
|
||||||
score_counter.display_digits(value)
|
score_counter.display_digits(value)
|
||||||
|
|
||||||
|
|
||||||
func update_shield(max_value, value):
|
func _on_shield_changed(max_value: int, old_value: int, new_value: int) -> void:
|
||||||
|
|
||||||
shield_bar.max_value = max_value
|
shield_bar.max_value = max_value
|
||||||
shield_bar.value = value
|
shield_bar.value = new_value
|
||||||
|
var shield_depletion = int(old_value - new_value)
|
||||||
|
print("Shield Depletion:", old_value, "-", new_value, " = ", shield_depletion)
|
||||||
|
var tween = create_tween()
|
||||||
|
tween.tween_property(shield_bar, "value", new_value - shield_depletion, .20).set_trans(Tween.TRANS_LINEAR)
|
||||||
|
_on_fx_shield_ui()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_fx_shield_ui():
|
||||||
|
shader_active = true
|
||||||
|
shield_bar.material.set_shader_parameter("toggle", 1.0)
|
||||||
|
await get_tree().create_timer(1).timeout
|
||||||
|
shader_active = false
|
||||||
|
shield_bar.material.set_shader_parameter("toggle", 0.0)
|
||||||
|
|
|
||||||
12
ui.tscn
12
ui.tscn
|
|
@ -1,10 +1,15 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://s6wf3egdqtmh"]
|
[gd_scene load_steps=7 format=3 uid="uid://s6wf3egdqtmh"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://d11molrkdjjh5" path="res://bar_background.png" id="1_m6e0p"]
|
[ext_resource type="Texture2D" uid="uid://d11molrkdjjh5" path="res://bar_background.png" id="1_m6e0p"]
|
||||||
[ext_resource type="Script" uid="uid://b544c65halgk4" path="res://ui.gd" id="1_nltto"]
|
[ext_resource type="Script" uid="uid://b544c65halgk4" path="res://ui.gd" id="1_nltto"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bsl3pxvxiuoqg" path="res://bar_foreground.png" id="2_27fn8"]
|
[ext_resource type="Texture2D" uid="uid://bsl3pxvxiuoqg" path="res://bar_foreground.png" id="2_27fn8"]
|
||||||
|
[ext_resource type="Shader" uid="uid://dfywtah53il1m" path="res://player_hit.gdshader" id="2_ibotj"]
|
||||||
[ext_resource type="PackedScene" uid="uid://5qkcf1cpre32" path="res://score_counter.tscn" id="4_ibotj"]
|
[ext_resource type="PackedScene" uid="uid://5qkcf1cpre32" path="res://score_counter.tscn" id="4_ibotj"]
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_n5ude"]
|
||||||
|
shader = ExtResource("2_ibotj")
|
||||||
|
shader_parameter/toggle = 0.0
|
||||||
|
|
||||||
[node name="UI" type="MarginContainer"]
|
[node name="UI" type="MarginContainer"]
|
||||||
anchors_preset = 10
|
anchors_preset = 10
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|
@ -20,8 +25,11 @@ script = ExtResource("1_nltto")
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="ShieldBar" type="TextureProgressBar" parent="HBoxContainer"]
|
[node name="ShieldBar" type="TextureProgressBar" parent="HBoxContainer"]
|
||||||
|
material = SubResource("ShaderMaterial_n5ude")
|
||||||
custom_minimum_size = Vector2(80, 16)
|
custom_minimum_size = Vector2(80, 16)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
step = 0.0
|
||||||
|
value = 100.0
|
||||||
nine_patch_stretch = true
|
nine_patch_stretch = true
|
||||||
stretch_margin_left = 3
|
stretch_margin_left = 3
|
||||||
stretch_margin_top = 3
|
stretch_margin_top = 3
|
||||||
|
|
@ -32,3 +40,5 @@ texture_progress = ExtResource("2_27fn8")
|
||||||
|
|
||||||
[node name="ScoreCounter" parent="HBoxContainer" instance=ExtResource("4_ibotj")]
|
[node name="ScoreCounter" parent="HBoxContainer" instance=ExtResource("4_ibotj")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
|
[connection signal="value_changed" from="HBoxContainer/ShieldBar" to="." method="_on_shield_bar_value_changed"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue