summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Basketball.gd23
1 files changed, 14 insertions, 9 deletions
diff --git a/Basketball.gd b/Basketball.gd
index 31642ae..d4abf21 100644
--- a/Basketball.gd
+++ b/Basketball.gd
@@ -1,20 +1,25 @@
extends RigidBody2D
-var angular_speed = PI
var start_position
+var do_reset = false
+
# Called when the node enters the scene tree for the first time.
func _ready():
start_position = position
- apply_central_impulse(Vector2(500, -800))
- pass # Replace with function body.
+ do_reset = true
+
+# Override the default physics when we want to manually reset the position and rotation.
+func _integrate_forces(state):
+ if do_reset:
+ state.transform.origin = start_position
+ state.linear_velocity = Vector2()
+
+ apply_central_impulse(Vector2(500, -800))
+ apply_torque_impulse(10000.0)
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-func _process(delta):
- rotation += angular_speed * delta
+ do_reset = false
func _input(event):
if event.is_action_pressed("shoot"):
- position = start_position
- rotation = 0
- apply_central_impulse(Vector2(500, -800))
+ do_reset = true