diff options
author | Logan <logan@cflip.net> | 2022-09-23 20:42:32 -0600 |
---|---|---|
committer | Logan <logan@cflip.net> | 2022-09-23 20:42:32 -0600 |
commit | c0d37da4fd91352f9fa9c7ff1219fea96283be17 (patch) | |
tree | e9af0f687b0b3cc663d39673ce4faea8663a99d3 /scripts/basketball.gd | |
parent | d0915c865ae0f56e05e92cee798dffa6b494a682 (diff) |
Created folders and renamed files and nodes to standard naming scheme.
Diffstat (limited to 'scripts/basketball.gd')
-rw-r--r-- | scripts/basketball.gd | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/basketball.gd b/scripts/basketball.gd new file mode 100644 index 0000000..40d189c --- /dev/null +++ b/scripts/basketball.gd @@ -0,0 +1,27 @@ +extends RigidBody2D + +var start_position +var do_reset = false +var is_reset = true + +# Called when the node enters the scene tree for the first time. +func _ready(): + start_position = position + +# Override the default physics when we want to manually reset the position and rotation. +func _integrate_forces(state): + if do_reset: + state.transform = Transform2D(0, start_position) + state.linear_velocity = Vector2() + state.angular_velocity = 0 + + do_reset = false + is_reset = true + +func _input(event): + if event.is_action_pressed("shoot"): + if is_reset: + apply_impulse(Vector2(10, 10), Vector2(500, -800)) + is_reset = false + else: + do_reset = true |