Add microtransactions

This commit is contained in:
Marvin Dalheimer 2025-01-26 15:48:01 +01:00
parent aa7e5c3358
commit 97b9c6f9d4
No known key found for this signature in database
GPG key ID: 44CAD3A9F1679D8D
4 changed files with 63 additions and 8 deletions

View file

@ -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="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"] [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/font_sizes/font_size = 32
Button/fonts/font = null 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"] [node name="Game" type="Node2D"]
script = ExtResource("1_lnu2h") script = ExtResource("1_lnu2h")
@ -112,7 +116,7 @@ offset_left = 17.0
offset_top = 8.0 offset_top = 8.0
offset_right = 245.0 offset_right = 245.0
offset_bottom = 96.0 offset_bottom = 96.0
text = "Points: " text = " SOAP: "
label_settings = ExtResource("5_iywne") label_settings = ExtResource("5_iywne")
[node name="Points" type="Label" parent="."] [node name="Points" type="Label" parent="."]
@ -133,9 +137,31 @@ parameters/looping = true
position = Vector2(-5.00003, 208) position = Vector2(-5.00003, 208)
rotation = 0.940732 rotation = 0.940732
[node name="TouchScreenButton" type="TouchScreenButton" parent="."] [node name="Backdrop" type="ColorRect" parent="."]
position = Vector2(594, 257) 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_down" from="Button" to="." method="_on_button_button_down"]
[connection signal="button_up" from="Button" to="." method="_on_button_button_up"] [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="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"]

View file

@ -14,5 +14,34 @@ func _on_button_button_up():
$AnimationPlayer.current_animation = "blower_down" $AnimationPlayer.current_animation = "blower_down"
func _on_points_timer_timeout(): func _on_points_timer_timeout():
if State.blowing: if State.blowing && State.points > 0:
State.points += 1 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

View file

@ -24,7 +24,7 @@ func _process(_delta):
# Convert magnitude to dB # Convert magnitude to dB
var db = linear_to_db(max_magnitude) var db = linear_to_db(max_magnitude)
print("Volume (dB): ", db) #print("Volume (dB): ", db)
if State.blower_up: if State.blower_up:
if db > -50: if db > -50:

View file

@ -3,4 +3,4 @@ extends Node
var blower_up := false var blower_up := false
var blowing := false var blowing := false
var points := 0 var points: int = 40