From ed3b37f6fa7b37429f79a7d229e1134ae316ed7e Mon Sep 17 00:00:00 2001 From: cflip Date: Fri, 23 Sep 2022 17:23:06 -0600 Subject: Replace the basketball sprite object with a RigidBody2D This way we don't have to implement all of the physics ourselves. --- Basketball.gd | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Basketball.gd (limited to 'Basketball.gd') diff --git a/Basketball.gd b/Basketball.gd new file mode 100644 index 0000000..31642ae --- /dev/null +++ b/Basketball.gd @@ -0,0 +1,20 @@ +extends RigidBody2D + +var angular_speed = PI +var start_position + +# 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. + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + rotation += angular_speed * delta + +func _input(event): + if event.is_action_pressed("shoot"): + position = start_position + rotation = 0 + apply_central_impulse(Vector2(500, -800)) -- cgit v1.2.3