3 ms·
Here's my fix: http://jsfiddle.net/jlas/CT2pG/1/ http://jsfiddle.net/jlas/CT2pG/1/ Easy one line fix for this: need to check if new dx / dy is opposite the old
by jlas 13y ago
Here's my fix: http://jsfiddle.net/jlas/CT2pG/1/ http://jsfiddle.net/jlas/CT2pG/1/
Easy one line fix for this: need to check if new dx / dy is opposite the old dx / dy and use the old one if so.
var _dx = (e.keyCode - 38) % 2, _dy = (e.keyCode - 39) % 2;
dx = (_dx*-1 === dx) ? dx : _dx, dy = (_dy*-1 === dy) ? dy : _dy;
I also added another fix to disallow moving twice during one cycle.