+ var col = map.info.layer.find(l => l.type == "collision").data;
+
+ window.addEventListener("keydown", e => keys[e.keyCode] = true );
+ window.addEventListener("keyup" , e => keys[e.keyCode] = false);
+ setInterval(() => input(), 33.33)
+
+ function translate(x, y){
+ var sx = map.info.header.tilewidth * hero.stats.speed / 33.33;
+ var sy = map.info.header.tileheight * hero.stats.speed / 33.33;
+ var dx = x * sx, hx = hero.position[0];
+ var dy = y * sy, hy = hero.position[1];
+ var f = 2.1;
+
+ if (col[map.tileAt(hx + dx, hy + dy)] == 0 )
+ hero.place(hx + dx, hy + dy);
+ else if ( dy == 0 && col[map.tileAt(hx + dx / f, hy + sy / 1.5)] == 0 )
+ hero.place(hx + dx / f, hy + sy / 1.5);
+ else if ( dy == 0 && col[map.tileAt(hx + dx / f, hy - sy / 1.5)] == 0 )
+ hero.place(hx + dx / f, hy - sy / 1.5);
+ else if ( dx == 0 && col[map.tileAt(hx + sx / 1.5, hy + dy / f)] == 0 )
+ hero.place(hx + sx / 1.5, hy + dy / f);
+ else if ( dx == 0 && col[map.tileAt(hx - sx / 1.5, hy + dy / f)] == 0 )
+ hero.place(hx - sx / 1.5, hy + dy / f);
+ else player.stance();
+
+ map.center(hero.position[0], hero.position[1]);
+ }