From 1bac48ff8d64f46e3107a9133cadced30fee9468 Mon Sep 17 00:00:00 2001 From: Josh Guyette Date: Sun, 26 Jun 2022 22:03:36 -0500 Subject: [PATCH] refactored --- game/systems/GameLoop.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/game/systems/GameLoop.ts b/game/systems/GameLoop.ts index dbeee2b..6378067 100644 --- a/game/systems/GameLoop.ts +++ b/game/systems/GameLoop.ts @@ -5,7 +5,6 @@ import { } from "react-native-game-engine"; import { windowHeight, windowWidth } from "@game"; -import { Balloon } from "@entities"; export const GameLoop = ( entities: any, @@ -17,10 +16,11 @@ export const GameLoop = ( touches .filter((t: TouchEvent) => t.type === "press") .forEach((t: TouchEvent) => { - const balloonBody = entities.Balloon.body; - const balloonPos = balloonBody.position; - const { locationX, locationY } = t.event; - if (locationX < 50 && locationY < 50) { + const balloonBody = entities.Balloon.body as Matter.IBodyDefinition; + const balloonPos = balloonBody.position as Matter.Vector; + const { pageX, pageY } = t.event; + // if (locationX < 50 && locationY < 50) { // for some reason this works, but the line below is more readable. + if (Math.abs(pageX - balloonPos.x) < 50 && Math.abs(pageY - balloonPos.y) < 50) { dispatch({ type: "addToScore", });