diff --git a/death_screen/death_screen.gd b/death_screen/death_screen.gd new file mode 100644 index 0000000..21c68f6 --- /dev/null +++ b/death_screen/death_screen.gd @@ -0,0 +1,18 @@ +extends Control + +func _on_button_quit_pressed() -> void: + get_tree().quit() + +func _on_button_main_menu_pressed() -> void: + print("TODO") + pass # TODO + +func _on_player_player_died() -> void: + visible = true + + Engine.time_scale = 0.2 + + +func _on_button_retry_pressed() -> void: + get_tree().reload_current_scene() + Engine.time_scale = 1. diff --git a/death_screen/death_screen.gd.uid b/death_screen/death_screen.gd.uid new file mode 100644 index 0000000..bcf3d10 --- /dev/null +++ b/death_screen/death_screen.gd.uid @@ -0,0 +1 @@ +uid://cnulh0nwvoro3 diff --git a/death_screen/death_screen.tscn b/death_screen/death_screen.tscn index 98e33cc..035f2f1 100644 --- a/death_screen/death_screen.tscn +++ b/death_screen/death_screen.tscn @@ -1,4 +1,8 @@ -[gd_scene load_steps=2 format=3 uid="uid://dpdn2php3ydsv"] +[gd_scene load_steps=6 format=3 uid="uid://dpdn2php3ydsv"] + +[ext_resource type="Script" uid="uid://cnulh0nwvoro3" path="res://death_screen/death_screen.gd" id="1_03nxu"] +[ext_resource type="Theme" uid="uid://dwlus1hjwtch4" path="res://large_theme.tres" id="1_nk1bp"] +[ext_resource type="Theme" uid="uid://bn4i5ordp2chs" path="res://small_theme.tres" id="2_03nxu"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_aam3l"] bg_color = Color(0.5671965, 0.085610785, 0.1369414, 1) @@ -13,40 +17,88 @@ corner_radius_top_right = 20 corner_radius_bottom_right = 20 corner_radius_bottom_left = 20 -[node name="death_screen" type="MarginContainer"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3y8sy"] +bg_color = Color(0, 0, 0, 1) +corner_radius_top_left = 20 +corner_radius_top_right = 20 +corner_radius_bottom_right = 20 +corner_radius_bottom_left = 20 + +[node name="DeathScreen" type="Control"] +layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +script = ExtResource("1_03nxu") + +[node name="ColorRect" type="ColorRect" parent="."] +z_index = -1 +layout_mode = 0 +offset_right = 1920.0 +offset_bottom = 1080.0 +color = Color(0, 0, 0, 0.48235294) + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 0 +offset_right = 1920.0 +offset_bottom = 1080.0 theme_override_constants/margin_left = 50 theme_override_constants/margin_top = 50 theme_override_constants/margin_right = 50 theme_override_constants/margin_bottom = 50 -[node name="PanelContainer" type="PanelContainer" parent="."] +[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"] custom_minimum_size = Vector2(700, 200) layout_mode = 2 size_flags_horizontal = 4 size_flags_vertical = 0 theme_override_styles/panel = SubResource("StyleBoxFlat_aam3l") -[node name="RichTextLabel" type="RichTextLabel" parent="PanelContainer"] +[node name="RichTextLabel" type="RichTextLabel" parent="MarginContainer/PanelContainer"] layout_mode = 2 +theme = ExtResource("1_nk1bp") text = "YOU DIED" horizontal_alignment = 1 vertical_alignment = 1 -[node name="HBoxContainer" type="HBoxContainer" parent="."] +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] layout_mode = 2 size_flags_horizontal = 4 size_flags_vertical = 8 +theme = ExtResource("2_03nxu") -[node name="Button_Retry" type="Button" parent="HBoxContainer"] +[node name="PanelContainer" type="PanelContainer" parent="MarginContainer/VBoxContainer"] layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_3y8sy") -[node name="Button_Main_Menu" type="Button" parent="HBoxContainer"] +[node name="Button_Retry" type="Button" parent="MarginContainer/VBoxContainer/PanelContainer"] +custom_minimum_size = Vector2(400, 100) layout_mode = 2 +theme_type_variation = &"FlatButton" +text = "Play Again" -[node name="Button_Quit_Forever" type="Button" parent="HBoxContainer"] +[node name="PanelContainer2" type="PanelContainer" parent="MarginContainer/VBoxContainer"] layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_3y8sy") + +[node name="Button_Main_Menu" type="Button" parent="MarginContainer/VBoxContainer/PanelContainer2"] +custom_minimum_size = Vector2(400, 100) +layout_mode = 2 +theme_type_variation = &"FlatButton" +text = "Main Menu" + +[node name="PanelContainer3" type="PanelContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_3y8sy") + +[node name="Button_Quit" type="Button" parent="MarginContainer/VBoxContainer/PanelContainer3"] +custom_minimum_size = Vector2(400, 100) +layout_mode = 2 +theme_type_variation = &"FlatButton" +text = "Quit Forever" + +[connection signal="pressed" from="MarginContainer/VBoxContainer/PanelContainer/Button_Retry" to="." method="_on_button_retry_pressed"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/PanelContainer2/Button_Main_Menu" to="." method="_on_button_main_menu_pressed"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/PanelContainer3/Button_Quit" to="." method="_on_button_quit_pressed"] diff --git a/large_theme.tres b/large_theme.tres new file mode 100644 index 0000000..0275d64 --- /dev/null +++ b/large_theme.tres @@ -0,0 +1,5 @@ +[gd_resource type="Theme" format=3 uid="uid://dwlus1hjwtch4"] + +[resource] +default_base_scale = 5.0 +default_font_size = 52 diff --git a/main.tscn b/main.tscn index b4d9fc4..1fb61bd 100644 --- a/main.tscn +++ b/main.tscn @@ -7,6 +7,7 @@ [ext_resource type="Script" uid="uid://colvx6wq0e8n7" path="res://world/building_generator.gd" id="4_1bvp3"] [ext_resource type="PackedScene" uid="uid://4l3elvxpghw8" path="res://platform.tscn" id="4_5vw27"] [ext_resource type="PackedScene" uid="uid://cjsrtswk4vgf2" path="res://healthbar/healthbar.tscn" id="6_7mycd"] +[ext_resource type="PackedScene" uid="uid://dpdn2php3ydsv" path="res://death_screen/death_screen.tscn" id="7_5vw27"] [ext_resource type="PackedScene" uid="uid://dpv1w56yr1xue" path="res://traps/morning_star.tscn" id="7_272bh"] [node name="main" type="Node2D"] @@ -30,6 +31,10 @@ scale = Vector2(3, 3) position = Vector2(0, -50) ignore_rotation = false +[node name="Debug_Camera" type="Camera2D" parent="."] +scale = Vector2(41.020004, 41.020004) +zoom = Vector2(0.15, 0.15) + [node name="Building Generator" type="Node" parent="."] script = ExtResource("4_1bvp3") @@ -43,6 +48,9 @@ autostart = true offset_right = 128.0 offset_bottom = 128.0 +[node name="DeathScreen" parent="CanvasLayer" instance=ExtResource("7_5vw27")] +visible = false + [node name="MorningStar" parent="." instance=ExtResource("7_272bh")] position = Vector2(989, -2939) @@ -52,4 +60,6 @@ scale = Vector2(41.02, 41.02) zoom = Vector2(0.12, 0.12) [connection signal="health_changed" from="Player" to="CanvasLayer/Healthbar" method="_on_player_health_changed"] +[connection signal="player_died" from="Player" to="CanvasLayer/DeathScreen" method="_on_player_player_died"] [connection signal="timeout" from="Building Generator/Timer" to="Building Generator" method="_on_timer_timeout"] +[connection signal="visibility_changed" from="CanvasLayer/DeathScreen" to="Player" method="_on_death_screen_visibility_changed"] diff --git a/player/player.gd b/player/player.gd index 60c0043..ac8b8d3 100644 --- a/player/player.gd +++ b/player/player.gd @@ -5,6 +5,9 @@ extends CharacterBody2D @onready var earth_aligner : Node2D = $EarthAligner; @onready var sword : Area2D = $Sword; +# allow taking away player control +var handle_input : bool = true + # Gravity var earth_center = Vector2.ZERO; var max_fall_speed = 700; @@ -53,9 +56,10 @@ func manage_iframes(delta: float): func manage_attack(delta : float): atk_timer = max(0, atk_timer-delta) - if(Input.is_action_just_pressed("attack") and atk_timer <= 0): - sword.swing() - atk_timer = atk_cooldown + if handle_input: + if(Input.is_action_just_pressed("attack") and atk_timer <= 0): + sword.swing() + atk_timer = atk_cooldown func manage_movement_options() -> void: if(is_on_floor()): @@ -63,10 +67,11 @@ func manage_movement_options() -> void: func manage_animation() -> void: var walk_dir = 0 - if(Input.is_action_pressed("move_right")): - walk_dir += 1 - if(Input.is_action_pressed("move_left")): - walk_dir -= 1 + if(handle_input): + if(Input.is_action_pressed("move_right")): + walk_dir += 1 + if(Input.is_action_pressed("move_left")): + walk_dir -= 1 if(walk_dir != 0): facing = walk_dir @@ -84,15 +89,16 @@ func manage_velocity(delta: float) -> void: var local_velocity = Vector2(old_local_velocity.x/pow(1.7,60*delta), old_local_velocity.y); local_velocity += Vector2(0, gravity) - if(Input.is_action_pressed("move_right")): - local_velocity += Vector2(hspeed, 0) - if(Input.is_action_pressed("move_left")): - local_velocity += Vector2(-hspeed, 0) + if handle_input: + if(Input.is_action_pressed("move_right")): + local_velocity += Vector2(hspeed, 0) + if(Input.is_action_pressed("move_left")): + local_velocity += Vector2(-hspeed, 0) - if(Input.is_action_just_pressed("jump") and (is_on_floor() or air_jumps_current > 0)): - if(not is_on_floor()): - air_jumps_current -= 1; - local_velocity.y = -jump_strength + if(Input.is_action_just_pressed("jump") and (is_on_floor() or air_jumps_current > 0)): + if(not is_on_floor()): + air_jumps_current -= 1; + local_velocity.y = -jump_strength if(local_velocity.y > max_fall_speed): local_velocity.y = max_fall_speed @@ -115,3 +121,7 @@ func die(): if not dead: player_died.emit() dead = true + + +func _on_death_screen_visibility_changed() -> void: + handle_input = !handle_input diff --git a/small_theme.tres b/small_theme.tres new file mode 100644 index 0000000..445da0b --- /dev/null +++ b/small_theme.tres @@ -0,0 +1,5 @@ +[gd_resource type="Theme" format=3 uid="uid://bn4i5ordp2chs"] + +[resource] +default_base_scale = 2.0 +default_font_size = 32