modularised ball vendor
This commit is contained in:
@@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/play_bold.ttf-01ef2d4a837ad426c71b343ff0726d9
|
|||||||
Rendering=null
|
Rendering=null
|
||||||
antialiasing=1
|
antialiasing=1
|
||||||
generate_mipmaps=false
|
generate_mipmaps=false
|
||||||
|
disable_embedded_bitmaps=true
|
||||||
multichannel_signed_distance_field=false
|
multichannel_signed_distance_field=false
|
||||||
msdf_pixel_range=8
|
msdf_pixel_range=8
|
||||||
msdf_size=48
|
msdf_size=48
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/play_regular.ttf-923acfda0d8d8c618796c2897db6
|
|||||||
Rendering=null
|
Rendering=null
|
||||||
antialiasing=1
|
antialiasing=1
|
||||||
generate_mipmaps=false
|
generate_mipmaps=false
|
||||||
|
disable_embedded_bitmaps=true
|
||||||
multichannel_signed_distance_field=false
|
multichannel_signed_distance_field=false
|
||||||
msdf_pixel_range=8
|
msdf_pixel_range=8
|
||||||
msdf_size=48
|
msdf_size=48
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
signal on_try_buy_ball(id: int)
|
||||||
+5
-1
@@ -12,9 +12,13 @@ config_version=5
|
|||||||
|
|
||||||
config/name="Idle Breakout"
|
config/name="Idle Breakout"
|
||||||
run/main_scene="res://scenes/mainmenu.tscn"
|
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"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
SignalBus="*res://misc/signal_bus.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/viewport_width=1920
|
window/size/viewport_width=1920
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -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"]
|
||||||
+10
-7
@@ -4,17 +4,20 @@ var _current_level = 1
|
|||||||
var ball_basic_scene = preload("res://balls/basic/ball_basic.tscn")
|
var ball_basic_scene = preload("res://balls/basic/ball_basic.tscn")
|
||||||
var ball_speed_scene = preload("res://balls/speed/ball_speed.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):
|
func _physics_process(delta):
|
||||||
if $GameContent/Blocks.get_children().size() == 0:
|
if $GameContent/Blocks.get_children().size() == 0:
|
||||||
_current_level += 1
|
_current_level += 1
|
||||||
print("DONE")
|
|
||||||
|
|
||||||
func _on_button_basic_ball_pressed():
|
func _on_try_buy_ball(id: int):
|
||||||
var new_ball = ball_basic_scene.instantiate()
|
var new_ball
|
||||||
new_ball.global_position = $GameContent/BallSpawn.global_position
|
match id:
|
||||||
$GameContent/Balls.add_child(new_ball)
|
1:
|
||||||
|
new_ball = ball_basic_scene.instantiate()
|
||||||
|
2:
|
||||||
|
new_ball = ball_speed_scene.instantiate()
|
||||||
|
|
||||||
func _on_button_speed_ball_pressed():
|
|
||||||
var new_ball = ball_speed_scene.instantiate()
|
|
||||||
new_ball.global_position = $GameContent/BallSpawn.global_position
|
new_ball.global_position = $GameContent/BallSpawn.global_position
|
||||||
$GameContent/Balls.add_child(new_ball)
|
$GameContent/Balls.add_child(new_ball)
|
||||||
|
|||||||
+13
-17
@@ -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="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"]
|
[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://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="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="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="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="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"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3mf1b"]
|
||||||
bg_color = Color(0.341176, 0.392157, 0.564706, 1)
|
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"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="GUI/Panel/MarginContainer"]
|
||||||
layout_mode = 2
|
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
|
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"]
|
[node name="VendorSpeed" parent="GUI/Panel/MarginContainer/VBoxContainer" instance=ExtResource("4_y3846")]
|
||||||
custom_minimum_size = Vector2(100, 100)
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
texture_normal = ExtResource("4_phqmb")
|
_ball_texture = ExtResource("5_mxuen")
|
||||||
stretch_mode = 0
|
_ball_name = "Speed Ball"
|
||||||
|
_ball_id = 2
|
||||||
[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
|
|
||||||
|
|
||||||
[node name="GameContent" type="Node2D" parent="."]
|
[node name="GameContent" type="Node2D" parent="."]
|
||||||
|
|
||||||
@@ -169,5 +165,5 @@ position = Vector2(1635, 293)
|
|||||||
[node name="BallSpawn" type="Node2D" parent="GameContent"]
|
[node name="BallSpawn" type="Node2D" parent="GameContent"]
|
||||||
position = Vector2(1140, 540)
|
position = Vector2(1140, 540)
|
||||||
|
|
||||||
[connection signal="pressed" from="GUI/Panel/MarginContainer/VBoxContainer/HBoxContainer/ButtonBasicBall" to="." method="_on_button_basic_ball_pressed"]
|
[node name="BallVendor" type="Node2D" parent="."]
|
||||||
[connection signal="pressed" from="GUI/Panel/MarginContainer/VBoxContainer/HBoxContainer2/ButtonSpeedBall" to="." method="_on_button_speed_ball_pressed"]
|
script = ExtResource("9_qgihr")
|
||||||
|
|||||||
Reference in New Issue
Block a user