summaryrefslogtreecommitdiff
path: root/Basketball.gd
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2022-09-23 17:23:06 -0600
committercflip <cflip@cflip.net>2022-09-23 17:23:06 -0600
commited3b37f6fa7b37429f79a7d229e1134ae316ed7e (patch)
treee8424d06ac364327c32e18899bc7d837d042bb66 /Basketball.gd
parentc46bb2fca39de21df9c4abbdc9cbbf2262e8ace0 (diff)
Replace the basketball sprite object with a RigidBody2D
This way we don't have to implement all of the physics ourselves.
Diffstat (limited to 'Basketball.gd')
-rw-r--r--Basketball.gd20
1 files changed, 20 insertions, 0 deletions
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))