a game about throwing hammers made for the github game off
add death screen
| -rw-r--r-- | Main.gd | 6 | ||||
| -rw-r--r-- | Main.tscn | 12 | ||||
| -rw-r--r-- | autoloads/MusicPlayer.gd | 2 | ||||
| -rw-r--r-- | hammers/hammer.gd | 1 | ||||
| -rw-r--r-- | levels/LevelManager.gd | 4 | ||||
| -rw-r--r-- | player/player.gd | 19 | ||||
| -rw-r--r-- | ui/death.gd | 8 | ||||
| -rw-r--r-- | ui/death.tscn | 224 | ||||
| -rw-r--r-- | ui/hud/health_meter.gd | 2 | ||||
| -rw-r--r-- | ui/main.theme.tres | 1 | ||||
| -rw-r--r-- | ui/start.gd | 7 | ||||
| -rw-r--r-- | ui/start.tscn | 3 |
12 files changed, 264 insertions, 25 deletions
@@ -1,7 +1 @@ extends Node2D - -func _ready() -> void: - MusicPlayer.p() - -func _exit_tree() -> void: - MusicPlayer.s() @@ -1,4 +1,4 @@ -[gd_scene load_steps=24 format=3 uid="uid://06slp4crd6oj"] +[gd_scene load_steps=25 format=3 uid="uid://06slp4crd6oj"] [ext_resource type="Script" path="res://Main.gd" id="1_l4fqe"] [ext_resource type="PackedScene" uid="uid://cl03k3yc8fxkt" path="res://player/player.tscn" id="1_ug1uc"] @@ -23,17 +23,18 @@ [ext_resource type="PackedScene" uid="uid://pk206siyyege" path="res://levels/rand/17.tscn" id="20_f85eu"] [ext_resource type="PackedScene" uid="uid://dbcrx23xsfrlp" path="res://levels/rand/18.tscn" id="21_rvdjm"] [ext_resource type="PackedScene" uid="uid://bnsgjilr4mn10" path="res://ui/hud/hud.tscn" id="23_5dqpk"] +[ext_resource type="PackedScene" uid="uid://bn6ky6p73m8ql" path="res://ui/death.tscn" id="24_4kagl"] [node name="Main" type="Node2D"] texture_filter = 1 script = ExtResource("1_l4fqe") -[node name="player" parent="." instance=ExtResource("1_ug1uc")] +[node name="player" parent="." node_paths=PackedStringArray("death") instance=ExtResource("1_ug1uc")] position = Vector2(128, 96) +death = NodePath("../death/death") [node name="Start" parent="." instance=ExtResource("2_vg2cv")] layer_0/tile_data = PackedInt32Array(131072, 0, 1, 196608, 0, 1, 262144, 262144, 1, 327680, 196608, 1, 393216, 196608, 2, 589824, 196608, 0, 655360, 196608, 1, 720896, 262144, 2, 786432, 0, 1, 851968, 0, 1, 917504, 0, 1, 983040, 0, 2, 983041, 65536, 2, 2, 65536, 0, 983042, 327680, 3, 3, 65536, 0, 983043, 65536, 3, 4, 65536, 0, 983044, 65536, 3, 5, 327680, 0, 983045, 65536, 3, 6, 131072, 3, 393222, 0, 0, 524294, 0, 1, 589830, 0, 2, 983046, 131072, 3, 524295, 65536, 1, 589831, 65536, 2, 393224, 65536, 0, 458760, 65536, 1, 524296, 65536, 1, 589832, 65536, 2, 9, 0, 0, 393225, 131072, 0, 458761, 131072, 1, 524297, 131072, 1, 589833, 131072, 2, 983049, 0, 3, 10, 327680, 0, 983050, 65536, 3, 11, 65536, 3, 983051, 65536, 3, 12, 393216, 0, 983052, 65536, 3, 13, 65536, 0, 983053, 65536, 3, 14, 65536, 0, 983054, 65536, 3, 15, 131072, 0, 65551, 458752, 1, 131087, 196608, 1, 196623, 196608, 1, 262159, 196608, 1, 327695, 196608, 1, 393231, 196608, 2, 589839, 196608, 0, 655375, 196608, 1, 720911, 196608, 1, 786447, 196608, 1, 851983, 196608, 1, 917519, 196608, 1, 983055, 458752, 3, 65536, 0, 1, 0, 0, 0, 1, 65536, 0, 458758, 0, 1, 393223, 65536, 0, 458759, 65536, 1, 917516, 196609, 0, 917517, 262145, 0, 851982, 196609, 0, 917518, 327681, 0, 917505, 65536, 1, 917506, 131072, 1, 851970, 131072, 0, 851969, 327680, 2, 786433, 131072, 1, 720897, 131072, 0, 786439, 0, 0, 786440, 327680, 0, 851976, 131072, 2, 851975, 0, 2, 786441, 131072, 3, 393220, 196608, 2, 327684, 196608, 1, 262148, 458752, 1, 393228, 196608, 0, 458764, 196608, 1, 524300, 196608, 1, 589836, 196608, 2, 262147, 65536, 2, 262146, 65536, 2, 262145, 65536, 2, 196609, 65536, 1, 131073, 65536, 1, 65537, 65536, 1, 65538, 65536, 1, 131074, 65536, 1, 196610, 65536, 1, 65539, 65536, 1, 131075, 65536, 1, 196611, 65536, 1, 196612, 131072, 1, 131076, 327680, 1, 131077, 131072, 2, 65540, 65536, 1, 65548, 0, 1, 65549, 327680, 1, 131085, 458752, 1, 131084, 0, 2, 196621, 196608, 2, 65550, 65536, 2, 65546, 131072, 1, 131082, 131072, 2, 65545, 0, 1, 131081, 262144, 1, 196617, 196608, 2, 65541, 131072, 1) -layer_0/tile_data = PackedInt32Array(131072, 0, 1, 196608, 0, 1, 262144, 262144, 1, 327680, 196608, 1, 393216, 196608, 2, 589824, 196608, 0, 655360, 196608, 1, 720896, 262144, 2, 786432, 0, 1, 851968, 0, 1, 917504, 0, 1, 983040, 0, 2, 983041, 65536, 2, 2, 65536, 0, 983042, 327680, 3, 3, 65536, 0, 983043, 65536, 3, 4, 65536, 0, 983044, 65536, 3, 5, 327680, 0, 983045, 65536, 3, 6, 131072, 3, 393222, 0, 0, 524294, 0, 1, 589830, 0, 2, 983046, 131072, 3, 524295, 65536, 1, 589831, 65536, 2, 393224, 65536, 0, 458760, 65536, 1, 524296, 65536, 1, 589832, 65536, 2, 9, 0, 0, 393225, 131072, 0, 458761, 131072, 1, 524297, 131072, 1, 589833, 131072, 2, 983049, 0, 3, 10, 327680, 0, 983050, 65536, 3, 11, 65536, 3, 983051, 65536, 3, 12, 393216, 0, 983052, 65536, 3, 13, 65536, 0, 983053, 65536, 3, 14, 65536, 0, 983054, 65536, 3, 15, 131072, 0, 65551, 458752, 1, 131087, 196608, 1, 196623, 196608, 1, 262159, 196608, 1, 327695, 196608, 1, 393231, 196608, 2, 589839, 196608, 0, 655375, 196608, 1, 720911, 196608, 1, 786447, 196608, 1, 851983, 196608, 1, 917519, 196608, 1, 983055, 458752, 3, 65536, 0, 1, 0, 0, 0, 1, 65536, 0, 458758, 0, 1, 393223, 65536, 0, 458759, 65536, 1, 917516, 196609, 0, 917517, 262145, 0, 851982, 196609, 0, 917518, 327681, 0, 917505, 65536, 1, 917506, 131072, 1, 851970, 131072, 0, 851969, 327680, 2, 786433, 131072, 1, 720897, 131072, 0, 786439, 0, 0, 786440, 327680, 0, 851976, 131072, 2, 851975, 0, 2, 786441, 131072, 3, 393220, 196608, 2, 327684, 196608, 1, 262148, 458752, 1, 393228, 196608, 0, 458764, 196608, 1, 524300, 196608, 1, 589836, 196608, 2, 262147, 65536, 2, 262146, 65536, 2, 262145, 65536, 2, 196609, 65536, 1, 131073, 65536, 1, 65537, 65536, 1, 65538, 65536, 1, 131074, 65536, 1, 196610, 65536, 1, 65539, 65536, 1, 131075, 65536, 1, 196611, 65536, 1, 196612, 131072, 1, 131076, 327680, 1, 131077, 131072, 2, 65540, 65536, 1, 65548, 0, 1, 65549, 327680, 1, 131085, 458752, 1, 131084, 0, 2, 196621, 196608, 2, 65550, 65536, 2, 65546, 131072, 1, 131082, 131072, 2, 65545, 0, 1, 131081, 262144, 1, 196617, 196608, 2, 65541, 131072, 1) [node name="LevelManager" type="Node" parent="." node_paths=PackedStringArray("current_level", "player")] unique_name_in_owner = true @@ -51,3 +52,8 @@ position_smoothing_enabled = true [node name="HUD" parent="." instance=ExtResource("23_5dqpk")] layer = 0 + +[node name="death" type="CanvasLayer" parent="."] + +[node name="death" parent="death" instance=ExtResource("24_4kagl")] +visible = false diff --git a/autoloads/MusicPlayer.gd b/autoloads/MusicPlayer.gd index a08fb99..b5df309 100644 --- a/autoloads/MusicPlayer.gd +++ b/autoloads/MusicPlayer.gd @@ -9,7 +9,7 @@ func _ready() -> void: func p() -> void: stream = track pitch_scale = 1 + randf_range(-0.05, 0.05) - volume_db = -30 + volume_db = -20 play() func s() -> void: diff --git a/hammers/hammer.gd b/hammers/hammer.gd index 96cfc3c..c25a706 100644 --- a/hammers/hammer.gd +++ b/hammers/hammer.gd @@ -107,7 +107,6 @@ func _on_body_entered(_body: Node2D) -> void: ## Throws this [Hammer]. func throw(p_direction: Vector2) -> void: - print("throw") set_collision_layer_value(7, false) direction = p_direction trail.emitting = true diff --git a/levels/LevelManager.gd b/levels/LevelManager.gd index 45bf640..daa1bb2 100644 --- a/levels/LevelManager.gd +++ b/levels/LevelManager.gd @@ -34,9 +34,6 @@ var sorted := [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]] func _init() -> void: Globals.levelmanager = self -func _exit_tree() -> void: - Globals.levelmanager = null - func _ready() -> void: gen_map() lvl_position = size / 2 @@ -102,3 +99,4 @@ func gen_map() -> void: map.append(map_row) map[lvl_position.x][lvl_position.y] = start world_generated.emit(maze) + diff --git a/player/player.gd b/player/player.gd index 8e2618b..720ecc0 100644 --- a/player/player.gd +++ b/player/player.gd @@ -8,6 +8,10 @@ const WallJumpEffect := preload("res://fx/wall_dust.tscn") signal hp_changed(health: int) + +## Death overlay. +@export var death: Popuppable + ## Accel @export var accel := 512 @@ -74,6 +78,7 @@ var health := max_health: health = hp hp_changed.emit(hp) if hp == 0: + death.open() queue_free() @@ -139,14 +144,15 @@ func apply_friction(input: float) -> void: func hammer_highlight() -> void: if not current_hammer: - var hamms := pickup_area.get_overlapping_areas() - if hamms.is_empty(): - if last_highlit: + var unhighlight := func unhighlight() -> void: + if is_instance_valid(last_highlit): last_highlit.unhighlight() last_highlit = null + var hamms := pickup_area.get_overlapping_areas() + if hamms.is_empty(): + unhighlight.call() elif not last_highlit in hamms: - if last_highlit: - last_highlit.unhighlight() + unhighlight.call() last_highlit = hamms[0] hamms[0].highlight() @@ -292,6 +298,9 @@ func wall_detatch(wall_axis: int, delta: float) -> void: func hit(damage: int) -> void: health -= damage + for pad in Input.get_connected_joypads(): + Input.start_joy_vibration(pad, .3 * damage, .3 * damage, .5) + ## Disable the aim gizmo. func disable_aim_gizmo() -> void: diff --git a/ui/death.gd b/ui/death.gd new file mode 100644 index 0000000..9a51fb6 --- /dev/null +++ b/ui/death.gd @@ -0,0 +1,8 @@ +extends Popuppable + +func open() -> void: + $anim.play(&"death") + super() + +func _ready() -> void: + set_process_unhandled_input(false)
\ No newline at end of file diff --git a/ui/death.tscn b/ui/death.tscn new file mode 100644 index 0000000..1e19944 --- /dev/null +++ b/ui/death.tscn @@ -0,0 +1,224 @@ +[gd_scene load_steps=8 format=3 uid="uid://bn6ky6p73m8ql"] + +[ext_resource type="Theme" uid="uid://b5sr8elfovyw3" path="res://ui/main.theme.tres" id="1_nt3eu"] +[ext_resource type="Script" path="res://ui/death.gd" id="2_hhnyk"] + +[sub_resource type="GDScript" id="GDScript_oq2ol"] +resource_name = "retry" +script/source = "extends Button + +func _pressed() -> void: + get_tree().reload_current_scene() +" + +[sub_resource type="GDScript" id="GDScript_iaxx2"] +resource_name = "exit" +script/source = "extends Button + +func _pressed() -> void: + get_tree().change_scene_to_file(\"res://ui/start.tscn\") + MusicPlayer.s() +" + +[sub_resource type="Animation" id="Animation_m6ka6"] +resource_name = "death" +length = 1.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("cc/VBoxContainer/death:theme_override_colors/font_color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(0.960784, 0.32549, 0.32549, 1)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("cc/VBoxContainer/death:theme_override_font_sizes/font_size") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0.2, 0.5, 0.7), +"transitions": PackedFloat32Array(-2, 2, -2), +"update": 0, +"values": [40, 80, 50] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("cc/VBoxContainer/butts:modulate") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 0.5, 1.1), +"transitions": PackedFloat32Array(1, 1, -2), +"update": 0, +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 0), Color(1, 1, 1, 1)] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("cc/VBoxContainer/butts/retry:disabled") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.9, 4.70469), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 1, +"values": [true, false, true] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("cc/VBoxContainer/butts/exit:disabled") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0, 0.9, 4.70469), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 1, +"values": [true, false, true] +} + +[sub_resource type="Animation" id="Animation_fn85o"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("cc/VBoxContainer/death:theme_override_colors/font_color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(0.933333, 0.909804, 0.835294, 1)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("cc/VBoxContainer/death:theme_override_font_sizes/font_size") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [null] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("cc/VBoxContainer/butts:modulate") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 0)] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("cc/VBoxContainer/butts/retry:disabled") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("cc/VBoxContainer/butts/exit:disabled") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_whyfm"] +_data = { +"RESET": SubResource("Animation_fn85o"), +"death": SubResource("Animation_m6ka6") +} + +[node name="death" type="ColorRect" node_paths=PackedStringArray("focus")] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_nt3eu") +color = Color(0, 0, 0, 0.784314) +script = ExtResource("2_hhnyk") +focus = NodePath("cc/VBoxContainer/butts/retry") + +[node name="cc" type="CenterContainer" parent="."] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="cc"] +offset_left = 77.0 +offset_top = 79.0 +offset_right = 243.0 +offset_bottom = 241.0 + +[node name="death" type="Label" parent="cc/VBoxContainer"] +offset_right = 166.0 +offset_bottom = 44.0 +theme_override_colors/font_color = Color(0.933333, 0.909804, 0.835294, 1) +theme_override_font_sizes/font_size = 40 +text = "you died" +horizontal_alignment = 1 + +[node name="spacer" type="Control" parent="cc/VBoxContainer"] +custom_minimum_size = Vector2(0, 20) +layout_mode = 3 +anchors_preset = 0 +offset_top = 48.0 +offset_right = 166.0 +offset_bottom = 68.0 + +[node name="butts" type="VBoxContainer" parent="cc/VBoxContainer"] +modulate = Color(1, 1, 1, 0) +offset_top = 72.0 +offset_right = 166.0 +offset_bottom = 162.0 + +[node name="retry" type="Button" parent="cc/VBoxContainer/butts"] +offset_left = 20.0 +offset_right = 146.0 +offset_bottom = 43.0 +size_flags_horizontal = 4 +disabled = true +text = "try again" +script = SubResource("GDScript_oq2ol") + +[node name="exit" type="Button" parent="cc/VBoxContainer/butts"] +offset_left = 14.0 +offset_top = 47.0 +offset_right = 152.0 +offset_bottom = 90.0 +size_flags_horizontal = 4 +disabled = true +text = "main menu" +script = SubResource("GDScript_iaxx2") + +[node name="anim" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_whyfm") +} diff --git a/ui/hud/health_meter.gd b/ui/hud/health_meter.gd index 115287a..b77d7c5 100644 --- a/ui/hud/health_meter.gd +++ b/ui/hud/health_meter.gd @@ -13,4 +13,6 @@ func _ready(): func _hp_changed(hp: int): + if hp == 0: + full.hide() full.size.x = hp * 5 + 1 diff --git a/ui/main.theme.tres b/ui/main.theme.tres index b021ba2..96e0a14 100644 --- a/ui/main.theme.tres +++ b/ui/main.theme.tres @@ -28,4 +28,5 @@ Button/styles/normal = ExtResource("1_e241j") Button/styles/pressed = ExtResource("5_fceyb") CheckBox/icons/checked = ExtResource("6_4s2vy") CheckBox/icons/unchecked = ExtResource("7_4dnid") +Label/colors/font_color = Color(0.933333, 0.909804, 0.835294, 1) PanelContainer/styles/panel = ExtResource("6_s8neq") diff --git a/ui/start.gd b/ui/start.gd index 2d725f4..b884d6f 100644 --- a/ui/start.gd +++ b/ui/start.gd @@ -4,14 +4,11 @@ extends Popuppable func _ready() -> void: open() var buttons := get_tree().get_nodes_in_group(&"button") - var play_sound := func plays() -> void: randomize() ; SoundManager.play("click", -10, randf_range(.9, 1.1)) + var play_sound := func plays() -> void: randomize(); SoundManager.play("click", -10, randf_range(.9, 1.1)) for butt in buttons: if butt is Button: butt.pressed.connect(play_sound) elif butt is RemapButton: butt.button.pressed.connect(play_sound) butt.clear.pressed.connect(play_sound) - - -func exit() -> void: - pass + set_process_unhandled_input(false) diff --git a/ui/start.tscn b/ui/start.tscn index e0c9756..2a1bac4 100644 --- a/ui/start.tscn +++ b/ui/start.tscn @@ -9,7 +9,8 @@ resource_name = "start" script/source = "extends Button func _pressed() -> void: - get_tree().change_scene_to_file(\"res://Main.tscn\") + get_tree().change_scene_to_file(\"res://Main.tscn\") + MusicPlayer.p() " [sub_resource type="GDScript" id="GDScript_vtoxm"] |