diff --git a/Game.gd b/Game.gd index 19d7435..3a8cf79 100644 --- a/Game.gd +++ b/Game.gd @@ -1,6 +1,8 @@ extends Node2D +func _on_roller_failure(): + print("failure") -func _process(delta): - print($Evaluator.total_value) - + +func _on_roller_success(): + print("success") diff --git a/bottle/bottle.gd b/bottle/bottle.gd new file mode 100644 index 0000000..7edbaf4 --- /dev/null +++ b/bottle/bottle.gd @@ -0,0 +1,11 @@ +extends TileMap + + +# 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/collector/collector.gd b/collector/collector.gd index 1f80778..c9a4266 100644 --- a/collector/collector.gd +++ b/collector/collector.gd @@ -31,11 +31,9 @@ func _on_body_entered(body: Node2D): if body.collision_layer & collecting_collision_mask: var collectible: Collectible = body.get_node("Collectible") if collectible.type in collecting_types: - print("collezionato") collected_count += 1 collectible.collect() emit_signal("collected", body) if collected_count >= collecting_amount: - print("goal") emit_signal("goal") collected_count = 0 diff --git a/random/randomizer.gd b/random/randomizer.gd index 58577cf..1446f43 100644 --- a/random/randomizer.gd +++ b/random/randomizer.gd @@ -1,11 +1,3 @@ -extends Node2D - - -# 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 +extends Node +class_name Randomizer +static var rng : RandomNumberGenerator = RandomNumberGenerator.new() diff --git a/random/randomizer.tscn b/random/randomizer.tscn index cd30c30..d199a94 100644 --- a/random/randomizer.tscn +++ b/random/randomizer.tscn @@ -2,5 +2,5 @@ [ext_resource type="Script" path="res://random/randomizer.gd" id="1_nvy1v"] -[node name="Randomizer" type="Node2D"] +[node name="Randomizer" type="Node"] script = ExtResource("1_nvy1v") diff --git a/random/roller.gd b/random/roller.gd new file mode 100644 index 0000000..07587c0 --- /dev/null +++ b/random/roller.gd @@ -0,0 +1,14 @@ +extends Node2D + +@export_range(0,1) var slider : float = 0 + +signal success() + +signal failure() + +func roll(): + if Randomizer.rng.randf() < slider: + success.emit() + else: + failure.emit() + diff --git a/random/roller.tscn b/random/roller.tscn new file mode 100644 index 0000000..7c34586 --- /dev/null +++ b/random/roller.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dvgxb0ichkoe7"] + +[ext_resource type="Script" path="res://random/roller.gd" id="1_vetpi"] + +[node name="Roller" type="Node2D"] +script = ExtResource("1_vetpi") diff --git a/root.tscn b/root.tscn index eb5ba6d..4366dc9 100644 --- a/root.tscn +++ b/root.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://cbccs6kwwf265"] +[gd_scene load_steps=12 format=3 uid="uid://cbccs6kwwf265"] [ext_resource type="Script" path="res://root.gd" id="1_8jrhk"] [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_h26ax"] diff --git a/value/evaluator.gd b/value/evaluator.gd index 9492ef4..62040fb 100644 --- a/value/evaluator.gd +++ b/value/evaluator.gd @@ -25,19 +25,15 @@ func _on_body_entered(body): if body is PhysicsBody2D: if body.collision_layer & collecting_collision_mask: var evaluable: Valuable = body.get_node("Valuable") - print("sommato") total_value += evaluable.value evaluable.evaluate() score_changed.emit(total_value) - print("totale= "+str(total_value)) func _on_body_exited(body): if body is PhysicsBody2D: if body.collision_layer & collecting_collision_mask: var evaluable: Valuable = body.get_node("Valuable") - print("sottratto") total_value -= evaluable.value evaluable.evaluate() score_changed.emit(total_value) - print("totale= "+str(total_value))