diff options
author | Logan <logan@cflip.net> | 2022-09-26 00:04:03 -0600 |
---|---|---|
committer | Logan <logan@cflip.net> | 2022-09-26 00:04:03 -0600 |
commit | f5cc58b03a960a3ca5365c79e96bc7b5b1ca2b78 (patch) | |
tree | 7b97dffa9d773c611d6339297ff03443bffbb6a2 | |
parent | 105c6a3399f4c2396fc54ff69e82668956a7dfba (diff) |
Made starting position increase then randomize after scoring 5.
-rw-r--r-- | scenes/level.tscn | 5 | ||||
-rw-r--r-- | scripts/basketball.gd | 10 |
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() |