From 2449f36833c70b7a6d63fc0d5e34d68c7912f406 Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Sat, 4 Nov 2023 17:44:40 +0000 Subject: [PATCH] Step 4 --- App.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/App.js b/App.js index d962eae..b9b6a99 100644 --- a/App.js +++ b/App.js @@ -83,6 +83,22 @@ const Game = () => { ballAnimation.value.y + deviceMotionMeasurment.rotation.beta * 12 ), }; + + // Check if the ball is in the target + if ( + getIsBallInTarget({ + ballX: ballAnimation.value.x, + ballY: ballAnimation.value.y, + targetX: targetAnimation.value.x, + targetY: targetAnimation.value.y, + }) + ) { + // If it is, move the target to a new random position + targetAnimation.value = getRandomTargetPosition(); + + // And vibrate + Haptics.notificationAsync(); + } }); return subscription.remove; @@ -91,7 +107,6 @@ const Game = () => { return ( - );