godot-shooter / commit
Adding a source link to the pause menu.
Enemy.gd | 2 +- HUD.gd | 6 ++++++ World.gd | 11 ++++++++--- World.tscn | 56 +++++++++++++++++++++++++++++++++++++++++++++----------- 4 files changed, 60 insertions(+), 15 deletions(-) diff --git a/Enemy.gd b/Enemy.gd index 709c14b..9906f3c 100644 --- a/Enemy.gd +++ b/Enemy.gd @@ -48,7 +48,7 @@ func _physics_process(_delta: float) -> void: var player = players[0] var dist_to_player = global_position.distance_to(player.global_position) if ray_cast_2d.get_collider() == player and dist_to_player < (ray_length + 5): - player.hurt(2) + player.hurt(25) var explosion = Explosion.instance() explosion.transform = transform get_parent().add_child(explosion) diff --git a/HUD.gd b/HUD.gd index c9b750a..ebe8d99 100644 --- a/HUD.gd +++ b/HUD.gd @@ -16,6 +16,12 @@ onready var weapon_label = $MarginContainer2/HBoxContainer/Weapon onready var ammo_label = $MarginContainer2/HBoxContainer/Ammo func _input(event: InputEvent) -> void: + var nodes = get_tree().get_nodes_in_group("pause_menu") + var pause_menu = nodes[0] as Control + var is_pause_menu_open = pause_menu.visible + if is_pause_menu_open: + return + if event is InputEventScreenTouch and event.pressed: emit_signal("position_set", event.position) if event is InputEventScreenDrag: diff --git a/World.gd b/World.gd index 2c207a9..553be21 100644 --- a/World.gd +++ b/World.gd @@ -66,11 +66,11 @@ func create_weapon() -> PowerUp: weapon.position = get_new_environment_position(randf() + .5) var _err = weapon.connect("consumed", self, "weapon_consumed") var r = randf() - if r < .4: + if r < .45: weapon.data = Weapons.create_rocket_gun() weapon.label = "ROC" weapon.color = Color.red - elif r < .8: + elif r < .9: weapon.data = Weapons.create_gattling_gun() weapon.label = "SMG" weapon.color = Color.orange @@ -234,4 +234,9 @@ func restart() -> void: func _on_HUD_debug_signal() -> void: # completed_objectives = 5 - pass # Replace with function body. + pass + +func _on_LinkButton_pressed() -> void: + get_tree().paused = true + var _err = OS.shell_open("https://gitlab.com/PavelSafronov/godot-shooter") + get_tree().paused = true diff --git a/World.tscn b/World.tscn index 8c8bff5..5fb19d9 100644 --- a/World.tscn +++ b/World.tscn @@ -59,12 +59,12 @@ __meta__ = { [node name="Environment" type="Node2D" parent="."] [node name="UI" type="CanvasLayer" parent="."] +pause_mode = 2 [node name="HUD" parent="UI" instance=ExtResource( 3 )] pause_mode = 2 -[node name="PauseMenu" type="Control" parent="UI"] -pause_mode = 2 +[node name="PauseMenu" type="Control" parent="UI" groups=["pause_menu"]] visible = false anchor_right = 1.0 anchor_bottom = 1.0 @@ -75,28 +75,61 @@ anchor_right = 1.0 anchor_bottom = 1.0 [node name="PanelContainer" type="PanelContainer" parent="UI/PauseMenu/CenterContainer"] -margin_left = 236.0 +margin_left = 50.0 margin_top = 386.0 -margin_right = 264.0 +margin_right = 450.0 margin_bottom = 414.0 +rect_min_size = Vector2( 400, 0 ) [node name="VBoxContainer" type="VBoxContainer" parent="UI/PauseMenu/CenterContainer/PanelContainer"] margin_left = 14.0 margin_top = 14.0 -margin_right = 162.0 -margin_bottom = 125.0 +margin_right = 386.0 +margin_bottom = 227.0 [node name="Label" type="Label" parent="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer"] -margin_right = 148.0 -margin_bottom = 56.0 +margin_right = 372.0 +margin_bottom = 37.0 theme = ExtResource( 7 ) text = "Paused" align = 1 +[node name="TabContainer" type="TabContainer" parent="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer"] +margin_top = 45.0 +margin_right = 372.0 +margin_bottom = 168.0 + +[node name="About" type="VBoxContainer" parent="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer/TabContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 8.0 +margin_top = 61.0 +margin_right = -8.0 +margin_bottom = -8.0 + +[node name="RichTextLabel" type="RichTextLabel" parent="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer/TabContainer/About"] +margin_right = 356.0 +margin_bottom = 54.0 +rect_min_size = Vector2( 200, 0 ) +text = "Welcome to my Godot experiment." +fit_content_height = true + +[node name="Src" type="VBoxContainer" parent="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer/TabContainer"] +visible = false +margin_right = 40.0 +margin_bottom = 40.0 + +[node name="LinkButton" type="LinkButton" parent="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer/TabContainer/Src"] +margin_left = 8.0 +margin_top = 150.0 +margin_right = 208.0 +margin_bottom = 175.0 +text = "Source code" + [node name="Button" type="Button" parent="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer"] -margin_top = 64.0 -margin_right = 148.0 -margin_bottom = 111.0 +margin_top = 176.0 +margin_right = 372.0 +margin_bottom = 213.0 theme = ExtResource( 6 ) text = "Resume" @@ -160,5 +193,6 @@ antialiased = true [connection signal="debug_signal" from="UI/HUD" to="." method="_on_HUD_debug_signal"] [connection signal="paused" from="UI/HUD" to="." method="_on_HUD_paused"] [connection signal="position_set" from="UI/HUD" to="." method="set_destination"] +[connection signal="pressed" from="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer/TabContainer/Src/LinkButton" to="." method="_on_LinkButton_pressed"] [connection signal="pressed" from="UI/PauseMenu/CenterContainer/PanelContainer/VBoxContainer/Button" to="." method="_on_Button_pressed"] [connection signal="timeout" from="ShootTimer" to="." method="_on_ShootTimer_timeout"]