Compare commits
7 commits
main
...
signal-ref
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afc5c68569 | ||
|
|
9f2569a73c | ||
|
|
65a887e9db | ||
|
|
d739beb6f2 | ||
|
|
1ebba28e5d | ||
|
|
d64504189a | ||
|
|
ab8643d093 |
11 changed files with 130 additions and 71 deletions
7
event_bus.gd
Normal file
7
event_bus.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
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)
|
||||||
|
|
||||||
|
@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
|
||||||
40
main.tscn
40
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")
|
||||||
|
|
||||||
|
|
@ -86,6 +61,9 @@ 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, 270)
|
||||||
|
max_shield = null
|
||||||
|
speed = null
|
||||||
|
cooldown = null
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
libraries = {
|
libraries = {
|
||||||
|
|
@ -96,6 +74,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 +92,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"]
|
||||||
|
|
|
||||||
74
player.gd
74
player.gd
|
|
@ -1,19 +1,24 @@
|
||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
signal died
|
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,11 +46,33 @@ 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):
|
||||||
can_shoot = true
|
var old_value: int = shield
|
||||||
|
shield = min(max_shield, value)
|
||||||
|
EventBus.shield_changed.emit(max_shield, old_value, shield)
|
||||||
|
# shield_damage.emit() # Don't need this anymore since switching to event_bus.gd
|
||||||
|
if shield <= 0:
|
||||||
|
set_process(false)
|
||||||
|
$Ship.hide()
|
||||||
|
$Explosion.show()
|
||||||
|
$Explosion/AnimationPlayer.play("explosion-one-shot")
|
||||||
|
await $Explosion/AnimationPlayer.animation_finished
|
||||||
|
died.emit()
|
||||||
|
|
||||||
|
func _on_gun_cooldown_timeout() -> void:
|
||||||
|
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"):
|
||||||
|
|
@ -77,6 +84,7 @@ func _on_area_entered(area):
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
|
|
||||||
35
ui.gd
35
ui.gd
|
|
@ -3,10 +3,41 @@ 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
|
||||||
|
|
||||||
|
print("update_shield"," ","Current ",(new_value), " ", "(Max ",(max_value),")"," ","Old Value:"," ",(old_value))
|
||||||
|
|
||||||
|
if new_value >= max_value:
|
||||||
|
print("No need to tween!")
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("I should be tweening!")
|
||||||
|
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_shield_ui()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_shield_ui():
|
||||||
|
print("SHIELD FX!")
|
||||||
|
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