modularised ball vendor

This commit is contained in:
2024-11-13 15:30:05 +01:00
parent c3f84c7681
commit a12a965a2b
9 changed files with 80 additions and 26 deletions
+11 -8
View File
@@ -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)