summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scenes/level.tscn5
-rw-r--r--scripts/basketball.gd10
2 files changed, 13 insertions, 2 deletions
diff --git a/scenes/level.tscn b/scenes/level.tscn
index 946cbf5..fc0d753 100644
--- a/scenes/level.tscn
+++ b/scenes/level.tscn
@@ -14,7 +14,7 @@ d = 10.0
[node name="Interface" parent="." instance=ExtResource( 4 )]
[node name="Hoop" parent="." instance=ExtResource( 2 )]
-position = Vector2( 163, 38 )
+position = Vector2( 163, 37 )
[node name="Floor" type="StaticBody2D" parent="."]
position = Vector2( 684, 510 )
@@ -37,6 +37,7 @@ texture = ExtResource( 5 )
stretch_mode = 2
[node name="Basketball" parent="." instance=ExtResource( 3 )]
-position = Vector2( 31, 73 )
+position = Vector2( 123, 73 )
[connection signal="score" from="Hoop" to="Interface" method="_on_Hoop_score"]
+[connection signal="score" from="Hoop" to="Basketball" method="_on_Hoop_score"]
diff --git a/scripts/basketball.gd b/scripts/basketball.gd
index f36fa44..31d082a 100644
--- a/scripts/basketball.gd
+++ b/scripts/basketball.gd
@@ -86,3 +86,13 @@ func _on_InnerShape_mouse_entered():
ready_to_hold = true
func _on_InnerShape_mouse_exited():
ready_to_hold = false
+
+func position_changer():
+ if global_variables.score < 5:
+ start_position.x -= 20
+ start_position.x = clamp(start_position.x, 30, 123)
+ else:
+ start_position.x = rand_range(30, 123)
+
+func _on_Hoop_score():
+ position_changer()