From e360d70ca71f5bd9a53eb41e498cd4dca110ddab Mon Sep 17 00:00:00 2001 From: "sh919.park" Date: Tue, 18 Jun 2013 23:24:42 +0900 Subject: [PATCH] [DeviceMotionCapture] Modify the coordinate formula [Title] Modify the coordinate formula [Issue#] N_SE-40704 [Problem] The ball should not bounce on bottom right of the screen. [Solution] Modify the coordinate formula Change-Id: I86bc421ea88a1bc30a68b8d46e60bba32ca67d2c --- js/main.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/main.js b/js/main.js index efe9d5b..777655e 100755 --- a/js/main.js +++ b/js/main.js @@ -23,23 +23,23 @@ function deviceMotionEvents() { vx = vx * 0.98; vy = vy * 0.98; - x = parseInt(x + (vx / 20)); - y = parseInt(y + (vy / 20)); + x = parseInt(Math.round(x + (vx / 20))); + y = parseInt(Math.round(y + (vy / 20))); // Bound Check - if (x < 0) { + if (x <= 0) { x = 0; vx = -vx; } - if (y < 0) { + if (y <= 0) { y = 0; vy = -vy; } - if (x > document.documentElement.clientWidth - 80) { + if (x >= document.documentElement.clientWidth - 80) { x = document.documentElement.clientWidth - 80; vx = -vx; } - if (y > document.documentElement.clientHeight - 80) { + if (y >= document.documentElement.clientHeight - 80) { y = document.documentElement.clientHeight - 80; vy = -vy; } -- 2.7.4