Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -91,7 +107,6 @@ const Game = () => {
return (
<View style={styles.container}>
<Reanimated.View style={[styles.target, targetPosition]} />

<Reanimated.View style={[styles.ball, ballPosition]} />
</View>
);
Expand Down