godot-shooter / commit
Added fading instructions at the beginning.
HUD.gd | 5 +++- HUD.tscn | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++----------- Theme.tres | 12 +++++++++ World.gd | 2 +- 4 files changed, 89 insertions(+), 17 deletions(-) diff --git a/HUD.gd b/HUD.gd index 1fc8052..02cee1f 100644 --- a/HUD.gd +++ b/HUD.gd @@ -2,5 +2,8 @@ extends Control export var score = 0 +func _ready() -> void: + $AnimationPlayer.play("instructions fade") + func _process(_delta: float) -> void: - $HBoxContainer/Score.text = "%s" % score + $VBoxContainer/HBoxContainer/Score.text = "%s" % score diff --git a/HUD.tscn b/HUD.tscn index 9f3202a..04098df 100644 --- a/HUD.tscn +++ b/HUD.tscn @@ -1,34 +1,91 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=4 format=2] -[ext_resource path="res://assets/Unique.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://Theme.tres" type="Theme" id=1] [ext_resource path="res://HUD.gd" type="Script" id=2] -[sub_resource type="DynamicFont" id=1] -size = 100 -outline_size = 1 -outline_color = Color( 1, 0, 0, 1 ) -font_data = ExtResource( 1 ) - -[sub_resource type="Theme" id=2] -default_font = SubResource( 1 ) +[sub_resource type="Animation" id=1] +resource_name = "instructions fade" +length = 6.0 +tracks/0/type = "bezier" +tracks/0/path = NodePath("Label:modulate:r") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"points": PoolRealArray( ), +"times": PoolRealArray( ) +} +tracks/1/type = "bezier" +tracks/1/path = NodePath("Label:modulate:g") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"points": PoolRealArray( ), +"times": PoolRealArray( ) +} +tracks/2/type = "bezier" +tracks/2/path = NodePath("Label:modulate:b") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"points": PoolRealArray( ), +"times": PoolRealArray( ) +} +tracks/3/type = "bezier" +tracks/3/path = NodePath("Label:modulate:a") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"points": PoolRealArray( 1, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0 ), +"times": PoolRealArray( 0, 3 ) +} [node name="HUD" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 -theme = SubResource( 2 ) +theme = ExtResource( 1 ) script = ExtResource( 2 ) -[node name="HBoxContainer" type="HBoxContainer" parent="."] -anchor_right = 1.0 +[node name="VBoxContainer" type="VBoxContainer" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +margin_right = 956.0 +margin_bottom = 115.0 -[node name="ScoreText" type="Label" parent="HBoxContainer"] +[node name="ScoreText" type="Label" parent="VBoxContainer/HBoxContainer"] margin_right = 296.0 margin_bottom = 115.0 text = "Score: " -[node name="Score" type="Label" parent="HBoxContainer"] +[node name="Score" type="Label" parent="VBoxContainer/HBoxContainer"] margin_left = 300.0 margin_right = 426.0 margin_bottom = 115.0 text = "100" uppercase = true + +[node name="CenterContainer" type="CenterContainer" parent="VBoxContainer"] +margin_top = 119.0 +margin_right = 956.0 +margin_bottom = 234.0 + +[node name="Label" type="Label" parent="VBoxContainer/CenterContainer"] +margin_right = 956.0 +margin_bottom = 115.0 +theme = ExtResource( 1 ) +text = "Tap anywhere to travel" +align = 1 +valign = 1 + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +root_node = NodePath("../VBoxContainer/CenterContainer") +"anims/instructions fade" = SubResource( 1 ) diff --git a/Theme.tres b/Theme.tres new file mode 100644 index 0000000..3e186a5 --- /dev/null +++ b/Theme.tres @@ -0,0 +1,12 @@ +[gd_resource type="Theme" load_steps=3 format=2] + +[ext_resource path="res://assets/Unique.ttf" type="DynamicFontData" id=1] + +[sub_resource type="DynamicFont" id=1] +size = 100 +outline_size = 1 +outline_color = Color( 1, 0, 0, 1 ) +font_data = ExtResource( 1 ) + +[resource] +default_font = SubResource( 1 ) diff --git a/World.gd b/World.gd index 22c3ba6..5cfdf94 100644 --- a/World.gd +++ b/World.gd @@ -19,7 +19,7 @@ func add_new_enemy(should_be_visible: bool = false) -> void: var pos_angle = randi() % 360 var unit_vector = Vector2.UP.rotated(pos_angle) var screen_radius = get_viewport().get_visible_rect().size.length() / 2 + 10 - var enemy_spawn_dist = 300 if should_be_visible else screen_radius + var enemy_spawn_dist = 400 if should_be_visible else screen_radius var pos = unit_vector * enemy_spawn_dist + $Player.global_position var enemy = Enemy.instance()