summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/basketball.gd6
-rw-r--r--scripts/camera.gd4
2 files changed, 7 insertions, 3 deletions
diff --git a/scripts/basketball.gd b/scripts/basketball.gd
index cc9dfa6..cc794ce 100644
--- a/scripts/basketball.gd
+++ b/scripts/basketball.gd
@@ -11,7 +11,7 @@ var waiting_for_shoot = true
var mouse_over_ball = false
func _ready():
- start_position = position
+ start_position = global_position
# This function toggles between dragging the ball for a shot and allowing the physics engine to move
# the ball, setting any necessary properties along the way.
@@ -48,11 +48,11 @@ func _process(delta):
func _input(event):
if event.is_action_pressed("shoot") and mouse_over_ball and waiting_for_shoot:
is_dragging = true
- $Sprite.position = event.position - start_position
+ $Sprite.position = get_global_mouse_position() - start_position
$GhostSprite.visible = true
$GhostSprite.rotation = $Sprite.rotation
if is_dragging and event is InputEventMouseMotion:
- $Sprite.position = event.position - start_position
+ $Sprite.position = get_global_mouse_position() - start_position
# If the mouse pointer is beyond a certain radius, don't move the sprite any further from
# the start position while still keeping it at the same angle as the mouse pointer.
diff --git a/scripts/camera.gd b/scripts/camera.gd
new file mode 100644
index 0000000..264bc68
--- /dev/null
+++ b/scripts/camera.gd
@@ -0,0 +1,4 @@
+extends Camera2D
+
+func _process(_delta):
+ position = ($"../Basketball".position + $"../Hoop".position) / 2