diff --git a/fonts/play_bold.ttf.import b/fonts/play_bold.ttf.import index 4097832..965ce50 100644 --- a/fonts/play_bold.ttf.import +++ b/fonts/play_bold.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/play_bold.ttf-01ef2d4a837ad426c71b343ff0726d9 Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/fonts/play_regular.ttf.import b/fonts/play_regular.ttf.import index 7fd30b1..81793c9 100644 --- a/fonts/play_regular.ttf.import +++ b/fonts/play_regular.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/play_regular.ttf-923acfda0d8d8c618796c2897db6 Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/misc/ball_vendor.gd b/misc/ball_vendor.gd new file mode 100644 index 0000000..81a2136 --- /dev/null +++ b/misc/ball_vendor.gd @@ -0,0 +1,16 @@ +extends Node2D + +@export_group("Starting Prices") +@export_range(1, 1000) var _basic_ball: int +@export_range(1, 1000) var _speed_ball: int + +@onready var _price_basic_current = _basic_ball +@onready var _price_speed_current = _speed_ball + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass diff --git a/misc/signal_bus.gd b/misc/signal_bus.gd new file mode 100644 index 0000000..ceb57d6 --- /dev/null +++ b/misc/signal_bus.gd @@ -0,0 +1,3 @@ +extends Node + +signal on_try_buy_ball(id: int) diff --git a/project.godot b/project.godot index 3bb66ca..87c5b9e 100644 --- a/project.godot +++ b/project.godot @@ -12,9 +12,13 @@ config_version=5 config/name="Idle Breakout" run/main_scene="res://scenes/mainmenu.tscn" -config/features=PackedStringArray("4.2", "GL Compatibility") +config/features=PackedStringArray("4.3", "GL Compatibility") config/icon="res://icon.svg" +[autoload] + +SignalBus="*res://misc/signal_bus.gd" + [display] window/size/viewport_width=1920 diff --git a/scenes/ball_vendor_object.gd b/scenes/ball_vendor_object.gd new file mode 100644 index 0000000..077a269 --- /dev/null +++ b/scenes/ball_vendor_object.gd @@ -0,0 +1,14 @@ +extends HBoxContainer + +@export var _ball_texture: CompressedTexture2D +@export var _ball_name: String +@export var _ball_id: int + +func _ready(): + $BuyButton.texture_normal = _ball_texture + +func refresh_ball_price(new_price: int): + $PriceLabel.text = "%s" % new_price + +func _on_buy_button_pressed(): + SignalBus.on_try_buy_ball.emit(_ball_id) diff --git a/scenes/ball_vendor_object.tscn b/scenes/ball_vendor_object.tscn new file mode 100644 index 0000000..29c17af --- /dev/null +++ b/scenes/ball_vendor_object.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=2 format=3 uid="uid://s6hl2xf6o6sg"] + +[ext_resource type="Script" path="res://scenes/ball_vendor_object.gd" id="1_1tyxk"] + +[node name="BallVendorObject" type="HBoxContainer"] +script = ExtResource("1_1tyxk") + +[node name="BuyButton" type="TextureButton" parent="."] +custom_minimum_size = Vector2(100, 100) +layout_mode = 2 +stretch_mode = 0 + +[node name="PriceLabel" type="RichTextLabel" parent="."] +layout_mode = 2 + +[connection signal="pressed" from="BuyButton" to="." method="_on_buy_button_pressed"] diff --git a/scenes/level.gd b/scenes/level.gd index 77d954b..fcd20af 100644 --- a/scenes/level.gd +++ b/scenes/level.gd @@ -4,17 +4,20 @@ var _current_level = 1 var ball_basic_scene = preload("res://balls/basic/ball_basic.tscn") var ball_speed_scene = preload("res://balls/speed/ball_speed.tscn") +func _ready(): + SignalBus.on_try_buy_ball.connect(_on_try_buy_ball) + func _physics_process(delta): if $GameContent/Blocks.get_children().size() == 0: _current_level += 1 - print("DONE") -func _on_button_basic_ball_pressed(): - var new_ball = ball_basic_scene.instantiate() - new_ball.global_position = $GameContent/BallSpawn.global_position - $GameContent/Balls.add_child(new_ball) - -func _on_button_speed_ball_pressed(): - var new_ball = ball_speed_scene.instantiate() +func _on_try_buy_ball(id: int): + var new_ball + match id: + 1: + new_ball = ball_basic_scene.instantiate() + 2: + new_ball = ball_speed_scene.instantiate() + new_ball.global_position = $GameContent/BallSpawn.global_position $GameContent/Balls.add_child(new_ball) diff --git a/scenes/level.tscn b/scenes/level.tscn index d070165..85d6690 100644 --- a/scenes/level.tscn +++ b/scenes/level.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=3 uid="uid://bmscox3qtwvs2"] +[gd_scene load_steps=16 format=3 uid="uid://bmscox3qtwvs2"] [ext_resource type="Script" path="res://scenes/level.gd" id="1_3qps3"] [ext_resource type="Texture2D" uid="uid://c7wvhwsys1ll4" path="res://resources/backgrounds/levelbg.webp" id="1_7ct6t"] @@ -6,8 +6,10 @@ [ext_resource type="PackedScene" uid="uid://sl3jbnopo0yh" path="res://balls/basic/ball_basic.tscn" id="3_14yi2"] [ext_resource type="PackedScene" uid="uid://cbygje4vi2rkv" path="res://boundaries/world_boundary.tscn" id="4_455ct"] [ext_resource type="Texture2D" uid="uid://cxi0fqy5sajh5" path="res://balls/basic/basic.webp" id="4_phqmb"] +[ext_resource type="PackedScene" uid="uid://s6hl2xf6o6sg" path="res://scenes/ball_vendor_object.tscn" id="4_y3846"] [ext_resource type="Texture2D" uid="uid://dsqcbd2cffw6e" path="res://balls/speed/speed.webp" id="5_mxuen"] [ext_resource type="PackedScene" uid="uid://c1i1fp3xbp6ly" path="res://blocks/block.tscn" id="7_7fnx3"] +[ext_resource type="Script" path="res://misc/ball_vendor.gd" id="9_qgihr"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3mf1b"] bg_color = Color(0.341176, 0.392157, 0.564706, 1) @@ -82,23 +84,17 @@ theme_override_constants/margin_bottom = 12 [node name="VBoxContainer" type="VBoxContainer" parent="GUI/Panel/MarginContainer"] layout_mode = 2 -[node name="HBoxContainer" type="HBoxContainer" parent="GUI/Panel/MarginContainer/VBoxContainer"] +[node name="VendorBasic" parent="GUI/Panel/MarginContainer/VBoxContainer" instance=ExtResource("4_y3846")] layout_mode = 2 +_ball_texture = ExtResource("4_phqmb") +_ball_name = "Basic Ball" +_ball_id = 1 -[node name="ButtonBasicBall" type="TextureButton" parent="GUI/Panel/MarginContainer/VBoxContainer/HBoxContainer"] -custom_minimum_size = Vector2(100, 100) +[node name="VendorSpeed" parent="GUI/Panel/MarginContainer/VBoxContainer" instance=ExtResource("4_y3846")] layout_mode = 2 -texture_normal = ExtResource("4_phqmb") -stretch_mode = 0 - -[node name="HBoxContainer2" type="HBoxContainer" parent="GUI/Panel/MarginContainer/VBoxContainer"] -layout_mode = 2 - -[node name="ButtonSpeedBall" type="TextureButton" parent="GUI/Panel/MarginContainer/VBoxContainer/HBoxContainer2"] -custom_minimum_size = Vector2(100, 100) -layout_mode = 2 -texture_normal = ExtResource("5_mxuen") -stretch_mode = 0 +_ball_texture = ExtResource("5_mxuen") +_ball_name = "Speed Ball" +_ball_id = 2 [node name="GameContent" type="Node2D" parent="."] @@ -169,5 +165,5 @@ position = Vector2(1635, 293) [node name="BallSpawn" type="Node2D" parent="GameContent"] position = Vector2(1140, 540) -[connection signal="pressed" from="GUI/Panel/MarginContainer/VBoxContainer/HBoxContainer/ButtonBasicBall" to="." method="_on_button_basic_ball_pressed"] -[connection signal="pressed" from="GUI/Panel/MarginContainer/VBoxContainer/HBoxContainer2/ButtonSpeedBall" to="." method="_on_button_speed_ball_pressed"] +[node name="BallVendor" type="Node2D" parent="."] +script = ExtResource("9_qgihr")