summaryrefslogtreecommitdiff
path: root/scripts/basketball.gd
diff options
context:
space:
mode:
authorLogan <logan@cflip.net>2022-09-24 17:42:49 -0600
committerLogan <logan@cflip.net>2022-09-24 17:42:49 -0600
commitb41e2b9eeee4370b9f42d63708ab25ee81490996 (patch)
tree615d696519cb26a75a27a3c851758cda4aa41a75 /scripts/basketball.gd
parent286f4e6a2d70174d7bfb928ed1646ec03a5a37ab (diff)
Only throw basketball on mouse-release when cursor is near ball.
Diffstat (limited to 'scripts/basketball.gd')
-rw-r--r--scripts/basketball.gd15
1 files changed, 11 insertions, 4 deletions
diff --git a/scripts/basketball.gd b/scripts/basketball.gd
index 5435963..246af81 100644
--- a/scripts/basketball.gd
+++ b/scripts/basketball.gd
@@ -9,6 +9,7 @@ var start_position
var waiting_for_shoot = true
var power = 100
var spin_rotation = 0
+var ready_to_shoot
func _ready():
start_position = position
@@ -34,7 +35,7 @@ func _integrate_forces(state):
state.linear_velocity = Vector2()
state.angular_velocity = 0
-# Temporary controls to adjust power
+# Temporary testing controls
func _process(delta):
if waiting_for_shoot:
spin_rotation += spin_speed * delta
@@ -43,7 +44,6 @@ func _process(delta):
if Input.is_action_pressed("ui_right"):
start_position.x += move_speed * delta
start_position.x = clamp(start_position.x, 0, 1024)
-
if Input.is_action_pressed("ui_up"):
if power < 200:
power += 0.5
@@ -54,5 +54,12 @@ func _process(delta):
emit_signal("change_power", power)
func _input(event):
- if event.is_action_pressed("shoot"):
- toggle_mode()
+ if event.is_action_released("shoot"):
+ if ready_to_shoot or !waiting_for_shoot:
+ toggle_mode()
+
+func _on_Area2D_mouse_entered():
+ ready_to_shoot = true
+
+func _on_Area2D_mouse_exited():
+ ready_to_shoot = false