From ee6ea8b43aa1084d61d528fc849336b67d5817ee Mon Sep 17 00:00:00 2001 From: *anna* Date: Mon, 17 May 2021 15:27:45 +0200 Subject: [PATCH] boxi --- tree/park_N.html | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tree/park_N.html b/tree/park_N.html index 40e6207..07870af 100644 --- a/tree/park_N.html +++ b/tree/park_N.html @@ -84,40 +84,36 @@ $(document).keydown(function(e) { switch (e.which) { case 37: - /* $div.css('left', $div.offset().left - 20);*/ offset.left -= 20; console.log("left"); break; case 38: - // $div.css('top', $div.offset().top - 20); offset.top -= 20; console.log("top"); break; case 39: - //$div.css('left', $div.offset().left + 20); offset.left += 20; console.log("right"); break; case 40: - //$div.css('top', $div.offset().top + 20); offset.top += 20; console.log("down"); break; } //check the offset - if (offset.left < 0) { - offset.left = 0; + if (offset.left < 100) { + offset.left = 100; } - if (offset.left > $("#ground").width() - 50) { - offset.left = $("#ground").width() - 50; + if (offset.left > $("#ground").width() - 100) { + offset.left = $("#ground").width() - 100; } - if (offset.top < 0) { - offset.top = 0; + if (offset.top < 200) { + offset.top = 200; } - if (offset.top > $("#ground").height() - 100) { - offset.top = $("#ground").height() - 100; + if (offset.top > $("#ground").height() - 220) { + offset.top = $("#ground").height() - 220; }