diff --git a/TODO.md b/TODO.md index be594ab..f32bd5a 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,8 @@ 1. Visual polish - * visual indications when damage is done but a unit isn't killed * visual indication when a unit is stronger (eg. a little skull or star or something) * multiple square tiles to add variation 2. Sound effects - * on hit, especially when the unit isn't killed + * when a unit is killed * if possible, a small bit of background music 3. Gameplay additions: * powerups: change movement type, remove pawn's attack and movement restrictions diff --git a/assets/export/hit1.wav b/assets/export/hit1.wav new file mode 100644 index 0000000..f3bef1c Binary files /dev/null and b/assets/export/hit1.wav differ diff --git a/assets/export/hit2.wav b/assets/export/hit2.wav new file mode 100644 index 0000000..73c42b6 Binary files /dev/null and b/assets/export/hit2.wav differ diff --git a/assets/export/hit3.wav b/assets/export/hit3.wav new file mode 100644 index 0000000..b33ccd4 Binary files /dev/null and b/assets/export/hit3.wav differ diff --git a/assets/export/hit4.wav b/assets/export/hit4.wav new file mode 100644 index 0000000..541c589 Binary files /dev/null and b/assets/export/hit4.wav differ diff --git a/assets/source/voice_clips.aup b/assets/source/voice_clips.aup index f57d92a..c45b6e7 100644 --- a/assets/source/voice_clips.aup +++ b/assets/source/voice_clips.aup @@ -1,7 +1,75 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -124,7 +192,7 @@ - + @@ -134,7 +202,7 @@ - + diff --git a/assets/source/voice_clips_data/eff/d1f/eff1f023.au b/assets/source/voice_clips_data/eff/d1f/eff1f023.au new file mode 100644 index 0000000..bab9cb8 Binary files /dev/null and b/assets/source/voice_clips_data/eff/d1f/eff1f023.au differ diff --git a/assets/source/voice_clips_data/eff/d1f/eff1f3b6.au b/assets/source/voice_clips_data/eff/d1f/eff1f3b6.au new file mode 100644 index 0000000..a1f3701 Binary files /dev/null and b/assets/source/voice_clips_data/eff/d1f/eff1f3b6.au differ diff --git a/assets/source/voice_clips_data/eff/d1f/eff1f4a9.au b/assets/source/voice_clips_data/eff/d1f/eff1f4a9.au new file mode 100644 index 0000000..256768a Binary files /dev/null and b/assets/source/voice_clips_data/eff/d1f/eff1f4a9.au differ diff --git a/assets/source/voice_clips_data/eff/d1f/eff1f4ba.au b/assets/source/voice_clips_data/eff/d1f/eff1f4ba.au new file mode 100644 index 0000000..a349162 Binary files /dev/null and b/assets/source/voice_clips_data/eff/d1f/eff1f4ba.au differ diff --git a/assets/source/voice_clips_data/eff/d1f/eff1f671.au b/assets/source/voice_clips_data/eff/d1f/eff1f671.au new file mode 100644 index 0000000..6f33bfc Binary files /dev/null and b/assets/source/voice_clips_data/eff/d1f/eff1f671.au differ diff --git a/assets/source/voice_clips_data/eff/d1f/eff1f808.au b/assets/source/voice_clips_data/eff/d1f/eff1f808.au new file mode 100644 index 0000000..4ecfc84 Binary files /dev/null and b/assets/source/voice_clips_data/eff/d1f/eff1f808.au differ diff --git a/assets/source/voice_clips_data/eff/d1f/eff1fc1b.au b/assets/source/voice_clips_data/eff/d1f/eff1fc1b.au new file mode 100644 index 0000000..bd3a9b4 Binary files /dev/null and b/assets/source/voice_clips_data/eff/d1f/eff1fc1b.au differ diff --git a/assets/source/voice_clips_data/eff/d1f/eff1ff3d.au b/assets/source/voice_clips_data/eff/d1f/eff1ff3d.au new file mode 100644 index 0000000..ee876a7 Binary files /dev/null and b/assets/source/voice_clips_data/eff/d1f/eff1ff3d.au differ diff --git a/src/Game.gd b/src/Game.gd index d63897d..785b2e5 100644 --- a/src/Game.gd +++ b/src/Game.gd @@ -55,6 +55,13 @@ const piece_types = { "queen": "res://src/pieces/Queen.tscn", } +const hit_sounds = [ + "/root/Game/Hit1", + "/root/Game/Hit2", + "/root/Game/Hit3", + "/root/Game/Hit4", +] + func new_piece(piece_type, group, position = null): if not piece_types.has(piece_type): return null @@ -536,8 +543,11 @@ func _process(delta): else: # Deal damage target_square['piece'].health -= square['piece'].damage - # @TODO Sound effect - # @TODO Visual indication of damage dealt + var idx = self.rng.randi() % self.hit_sounds.size() + get_node(self.hit_sounds[idx]).play() + target_square['piece'].set_status( + "-" + str(square['piece'].damage), 2, Color(1, 0, 0, 1), Color(1, 0, 0, 0) + ) # Bounce piece back target_square = square square['piece'] = null @@ -631,8 +641,11 @@ func _physics_process(delta): print("ai loss Chance to play: ", c, " got index ", index_to_play) get_node(self.on_ai_lose_piece[index_to_play]).play() else: - # @TODO Play a sound effect - # @TODO Visual indication of damage dealt + var idx = self.rng.randi() % self.hit_sounds.size() + get_node(self.hit_sounds[idx]).play() + dest_square['piece'].set_status( + "-" + str(square['piece'].damage), 2, Color(1, 0, 0, 1), Color(1, 0, 0, 0) + ) dest_square['piece'].health -= square['piece'].damage dest_square = square square['piece'] = null diff --git a/src/Game.tscn b/src/Game.tscn index ea5fa21..339c148 100644 --- a/src/Game.tscn +++ b/src/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=2] +[gd_scene load_steps=26 format=2] [ext_resource path="res://src/Game.gd" type="Script" id=1] [ext_resource path="res://src/Playfield.tscn" type="PackedScene" id=2] @@ -18,6 +18,10 @@ [ext_resource path="res://assets/export/skip_disabled.png" type="Texture" id=16] [ext_resource path="res://assets/export/skip_hover.png" type="Texture" id=17] [ext_resource path="res://src/PieceDetails.tscn" type="PackedScene" id=18] +[ext_resource path="res://assets/export/hit2.wav" type="AudioStream" id=19] +[ext_resource path="res://assets/export/hit1.wav" type="AudioStream" id=20] +[ext_resource path="res://assets/export/hit3.wav" type="AudioStream" id=21] +[ext_resource path="res://assets/export/hit4.wav" type="AudioStream" id=22] [sub_resource type="DynamicFont" id=1] size = 24 @@ -235,6 +239,18 @@ margin_bottom = 14.0 __meta__ = { "_edit_use_anchors_": false } + +[node name="Hit1" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 20 ) + +[node name="Hit2" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 19 ) + +[node name="Hit3" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 21 ) + +[node name="Hit4" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 22 ) [connection signal="finished" from="EndSong" to="." method="_on_EndSong_finished"] [connection signal="finished" from="Yammering" to="." method="_on_Yammering_finished"] [connection signal="finished" from="Dust" to="." method="_on_Dust_finished"] diff --git a/src/Piece.gd b/src/Piece.gd index 42b974b..7eedd4e 100644 --- a/src/Piece.gd +++ b/src/Piece.gd @@ -22,6 +22,20 @@ const CLICK_THRESHOLD = 0.15 # seconds var last_click = null var hold_started = false +var status_timer_max = 0 +var status_timer = 0 +var status_color_start = Color(1, 1, 1, 1) +var status_color_end = Color(1, 1, 1, 0) + +func set_status(message, time, c1: Color = Color(1, 1, 1, 1), c2: Color = Color(1, 1, 1, 0)): + self.status_timer = time + self.status_timer_max = time + self.status_color_start = c1 + self.status_color_end = c2 + get_node("StatusChange").set_modulate(c1) + get_node("StatusChange").set_text(message) + get_node("StatusChange").set_visible(true) + # Called when the node enters the scene tree for the first time. func _ready(): pass @@ -66,7 +80,13 @@ func _process(delta): emit_signal("hold_start", self, null) if self.hold_started: self.set_global_position(get_viewport().get_mouse_position()) - + if self.status_timer > 0: + self.status_timer -= delta + if self.status_timer <= 0: + get_node("StatusChange").set_visible(false) + get_node("StatusChange").set_modulate( + lerp(self.status_color_end, self.status_color_start, self.status_timer / self.status_timer_max) + ) func cancel_hold(): self.last_click = null self.hold_started = false diff --git a/src/PieceDetails.tscn b/src/PieceDetails.tscn index 1026aac..9651761 100644 --- a/src/PieceDetails.tscn +++ b/src/PieceDetails.tscn @@ -85,16 +85,15 @@ custom_fonts/font = ExtResource( 1 ) text = "1 " [node name="UpHealth" type="Button" parent="Vbox"] -visible = false margin_top = 219.0 margin_right = 190.0 margin_bottom = 239.0 text = "Increase health" [node name="Damage" type="HBoxContainer" parent="Vbox"] -margin_top = 219.0 +margin_top = 243.0 margin_right = 190.0 -margin_bottom = 283.0 +margin_bottom = 307.0 [node name="TextureRect" type="TextureRect" parent="Vbox/Damage"] material = ExtResource( 3 ) @@ -118,9 +117,9 @@ margin_bottom = 307.0 text = "Increase damage" [node name="Kills" type="HBoxContainer" parent="Vbox"] -margin_top = 287.0 +margin_top = 311.0 margin_right = 190.0 -margin_bottom = 351.0 +margin_bottom = 375.0 [node name="TextureRect" type="TextureRect" parent="Vbox/Kills"] material = ExtResource( 3 ) @@ -137,24 +136,23 @@ custom_fonts/font = ExtResource( 1 ) text = "1" [node name="Jump" type="Label" parent="Vbox"] -margin_top = 355.0 +margin_top = 379.0 margin_right = 190.0 -margin_bottom = 379.0 +margin_bottom = 403.0 custom_fonts/font = SubResource( 1 ) text = "Cannot jump" [node name="CheckButton" type="CheckButton" parent="Vbox"] -visible = false -margin_top = 383.0 +margin_top = 407.0 margin_right = 190.0 -margin_bottom = 423.0 +margin_bottom = 447.0 text = "Jump" [node name="Powerup" type="Button" parent="Vbox"] visible = false -margin_top = 383.0 +margin_top = 427.0 margin_right = 190.0 -margin_bottom = 403.0 +margin_bottom = 447.0 text = "Spawn powerup" [connection signal="pressed" from="Vbox/UpMovement" to="." method="_on_UpMovement_pressed"] [connection signal="pressed" from="Vbox/UpHealth" to="." method="_on_UpHealth_pressed"] diff --git a/src/pieces/Pawn.tscn b/src/pieces/Pawn.tscn index f6add37..b927d95 100644 --- a/src/pieces/Pawn.tscn +++ b/src/pieces/Pawn.tscn @@ -1,25 +1,17 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=4 format=2] -[ext_resource path="res://src/hilight.shader" type="Shader" id=1] +[ext_resource path="res://src/pieces/Piece.tscn" type="PackedScene" id=1] [ext_resource path="res://src/pieces/Pawn.gd" type="Script" id=2] [ext_resource path="res://assets/export/pawn.png" type="Texture" id=3] -[sub_resource type="ShaderMaterial" id=1] -shader = ExtResource( 1 ) -shader_param/width = 2.0 -shader_param/color = null - -[sub_resource type="RectangleShape2D" id=2] -extents = Vector2( 128, 128 ) - -[node name="Piece" type="Area2D"] +[node name="Piece" instance=ExtResource( 1 )] script = ExtResource( 2 ) -[node name="Body" type="Sprite" parent="."] -material = SubResource( 1 ) +[node name="Body" parent="." index="0"] texture = ExtResource( 3 ) -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -modulate = Color( 0.345098, 0.980392, 0.0862745, 1 ) -shape = SubResource( 2 ) -[connection signal="input_event" from="." to="." method="_on_Piece_input_event"] +[node name="StatusChange" parent="." index="2"] +margin_left = 0.902771 +margin_top = -73.0833 +margin_right = 81.9028 +margin_bottom = -0.0833435 diff --git a/src/pieces/Piece.tscn b/src/pieces/Piece.tscn index 38bd6f8..d08985e 100644 --- a/src/pieces/Piece.tscn +++ b/src/pieces/Piece.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://src/Piece.gd" type="Script" id=1] [ext_resource path="res://src/hilight.shader" type="Shader" id=2] +[ext_resource path="res://src/font_32.tres" type="DynamicFont" id=3] [sub_resource type="ShaderMaterial" id=1] shader = ExtResource( 2 ) @@ -9,7 +10,7 @@ shader_param/width = 2.0 shader_param/color = null [sub_resource type="RectangleShape2D" id=2] -extents = Vector2( 128, 128 ) +extents = Vector2( 64, 64 ) [node name="Piece" type="Area2D"] script = ExtResource( 1 ) @@ -19,4 +20,16 @@ material = SubResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 2 ) + +[node name="StatusChange" type="Label" parent="."] +margin_left = 45.0 +margin_top = -126.0 +margin_right = 126.0 +margin_bottom = -53.0 +custom_fonts/font = ExtResource( 3 ) +align = 1 +valign = 1 +__meta__ = { +"_edit_use_anchors_": false +} [connection signal="input_event" from="." to="." method="_on_Piece_input_event"]