Made a proper death-screen
This commit is contained in:
parent
8c5d3cc126
commit
9160f7240f
7 changed files with 125 additions and 28 deletions
18
death_screen/death_screen.gd
Normal file
18
death_screen/death_screen.gd
Normal file
|
|
@ -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.
|
||||
1
death_screen/death_screen.gd.uid
Normal file
1
death_screen/death_screen.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cnulh0nwvoro3
|
||||
|
|
@ -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"]
|
||||
|
|
|
|||
5
large_theme.tres
Normal file
5
large_theme.tres
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[gd_resource type="Theme" format=3 uid="uid://dwlus1hjwtch4"]
|
||||
|
||||
[resource]
|
||||
default_base_scale = 5.0
|
||||
default_font_size = 52
|
||||
16
main.tscn
16
main.tscn
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://cxo6bq26huau7"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://cxo6bq26huau7"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"]
|
||||
[ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="2_lquwl"]
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://jjoyj1ldafkf" path="res://world/earth.tscn" id="3_lquwl"]
|
||||
[ext_resource type="Script" uid="uid://colvx6wq0e8n7" path="res://world/building_generator.gd" id="4_1bvp3"]
|
||||
[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"]
|
||||
|
|
@ -17,10 +18,6 @@ script = ExtResource("2_lquwl")
|
|||
[node name="Ghost" parent="." instance=ExtResource("3_h2yge")]
|
||||
position = Vector2(0, -3200)
|
||||
|
||||
[node name="Debug_Camera" type="Camera2D" parent="."]
|
||||
scale = Vector2(41.020004, 41.020004)
|
||||
zoom = Vector2(0.15, 0.15)
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("2_1bvp3")]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2(500, -3100)
|
||||
|
|
@ -30,6 +27,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,8 +44,13 @@ 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)
|
||||
|
||||
[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"]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
5
small_theme.tres
Normal file
5
small_theme.tres
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[gd_resource type="Theme" format=3 uid="uid://bn4i5ordp2chs"]
|
||||
|
||||
[resource]
|
||||
default_base_scale = 2.0
|
||||
default_font_size = 32
|
||||
Loading…
Add table
Reference in a new issue