diff --git a/scenes/game.tscn b/scenes/game.tscn index e051ecc..51df07d 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=3 uid="uid://bwe0t2hwl5pv1"] +[gd_scene load_steps=14 format=3 uid="uid://bwe0t2hwl5pv1"] [ext_resource type="Script" uid="uid://b6if2dhse646b" path="res://scripts/game.gd" id="1_lnu2h"] [ext_resource type="PackedScene" uid="uid://j473t8iwu45y" path="res://scenes/blower.tscn" id="1_uwrxv"] @@ -66,6 +66,10 @@ _data = { Button/font_sizes/font_size = 32 Button/fonts/font = null +[sub_resource type="Theme" id="Theme_u5sy4"] +AcceptDialog/font_sizes/title_font_size = 16 +Label/font_sizes/font_size = 48 + [node name="Game" type="Node2D"] script = ExtResource("1_lnu2h") @@ -112,7 +116,7 @@ offset_left = 17.0 offset_top = 8.0 offset_right = 245.0 offset_bottom = 96.0 -text = "Points: " +text = " SOAP: " label_settings = ExtResource("5_iywne") [node name="Points" type="Label" parent="."] @@ -133,9 +137,31 @@ parameters/looping = true position = Vector2(-5.00003, 208) rotation = 0.940732 -[node name="TouchScreenButton" type="TouchScreenButton" parent="."] -position = Vector2(594, 257) +[node name="Backdrop" type="ColorRect" parent="."] +visible = false +offset_left = -57.0 +offset_top = -33.0 +offset_right = 1247.0 +offset_bottom = 738.0 +color = Color(0.227451, 0.227451, 0.227451, 0.615686) + +[node name="Microtransaction" type="ConfirmationDialog" parent="."] +title = "Buy more Bubbles" +initial_position = 2 +size = Vector2i(500, 300) +unresizable = true +min_size = Vector2i(200, 300) +max_size = Vector2i(500, 350) +theme = SubResource("Theme_u5sy4") +ok_button_text = "Buy" +dialog_text = "Get more bubble soap for only 9.99$" +dialog_close_on_escape = false +dialog_autowrap = true +cancel_button_text = "Buy 2x" [connection signal="button_down" from="Button" to="." method="_on_button_button_down"] [connection signal="button_up" from="Button" to="." method="_on_button_button_up"] +[connection signal="mouse_exited" from="Button" to="." method="_on_button_mouse_exited"] [connection signal="timeout" from="PointsTimer" to="." method="_on_points_timer_timeout"] +[connection signal="canceled" from="Microtransaction" to="." method="_on_microtransaction_canceled"] +[connection signal="confirmed" from="Microtransaction" to="." method="_on_microtransaction_confirmed"] diff --git a/scripts/game.gd b/scripts/game.gd index 915259f..dd7f392 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -14,5 +14,34 @@ func _on_button_button_up(): $AnimationPlayer.current_animation = "blower_down" func _on_points_timer_timeout(): - if State.blowing: - State.points += 1 + if State.blowing && State.points > 0: + State.points -= 1 + + if State.points == 0: + $Button.button_pressed = false + $Button.release_focus() + State.blower_up = false + State.blowing = false + $AnimationPlayer.current_animation = "blower_down" + + $PointsTimer.paused = true + $Microtransaction.visible = true + $Backdrop.visible = true + + +func _on_microtransaction_canceled() -> void: + State.points = 80 + $PointsTimer.paused = false + $Microtransaction.visible = false + $Backdrop.visible = false + + +func _on_microtransaction_confirmed() -> void: + State.points = 40 + $PointsTimer.paused = false + $Microtransaction.visible = false + $Backdrop.visible = false + + +func _on_button_mouse_exited() -> void: + $Button.button_pressed = false diff --git a/scripts/recorder.gd b/scripts/recorder.gd index 653142b..be956f9 100644 --- a/scripts/recorder.gd +++ b/scripts/recorder.gd @@ -24,7 +24,7 @@ func _process(_delta): # Convert magnitude to dB var db = linear_to_db(max_magnitude) - print("Volume (dB): ", db) + #print("Volume (dB): ", db) if State.blower_up: if db > -50: diff --git a/scripts/state.gd b/scripts/state.gd index f871c43..c0fc577 100644 --- a/scripts/state.gd +++ b/scripts/state.gd @@ -3,4 +3,4 @@ extends Node var blower_up := false var blowing := false -var points := 0 +var points: int = 40