From 2d653bcc2d60677217092bc575278fd4fb901a99 Mon Sep 17 00:00:00 2001 From: neingeist Date: Sun, 7 Sep 2014 19:45:51 +0200 Subject: [PATCH] avoid the scroll bars --- herzle.html | 1 + herzle.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/herzle.html b/herzle.html index 1db94b8..eb16fa9 100644 --- a/herzle.html +++ b/herzle.html @@ -8,6 +8,7 @@ font-size: 50px; color: #ff00ff; font-family: helvetica, arial; + overflow: hidden; } #player { position: absolute; diff --git a/herzle.js b/herzle.js index 9511068..20c6307 100644 --- a/herzle.js +++ b/herzle.js @@ -13,10 +13,14 @@ function onKeyDown(e) { e = e || window.event; if (e.keyCode == '37') { // left - player_pos[0] -= 10; + if (player_pos[0] - 10 >= 0) { + player_pos[0] -= 10; + } } if (e.keyCode == '39') { // right - player_pos[0] += 10; + if (player_pos[0] + 10 <= window.innerWidth) { + player_pos[0] += 10; + } } if (e.keyCode == '32') { // space = fire if ((new Date()).getTime() - lastshoot > 300) {