Compare commits

..

No commits in common. "352c3aa16d6f8185388edabd18e7e54d6326eaf6" and "6b7ff7e86d813543a889c9cfec9d4dda66be60a0" have entirely different histories.

5 changed files with 10 additions and 92 deletions

View file

@ -1,42 +1,11 @@
{ {
"world": [ "dimensions": [32, 32],
" w ",
" w ",
" wwwwwww w wwwwwww ",
" w w ",
" w w ",
" w wwwwwwwwwwwww w ",
" w w ",
" w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
"www w wwwwwwwwwwwwwww w www",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w ",
" w w ",
" w wwwwwwwwwwwww w ",
" w w ",
" w w ",
" wwwwwww w wwwwwww ",
" w ",
" w "
],
"delay": 200, "delay": 200,
"food": [],
"snake": [ "snake": [
[16, 3], [16, 12],
[15, 3], [16, 11],
[14, 3] [16, 10]
], ],
"rules": { "rules": {
"worldWrap": false, "worldWrap": false,

View file

@ -19,5 +19,5 @@
[6,8], [6,8],
[6,9] [6,9]
], ],
"delay": 150 "delay": 100
} }

View file

@ -1,41 +0,0 @@
{
"world": [
" w ",
" w ",
" wwwwwww w wwwwwww ",
" w f w ",
" w w ",
" w wwwwwwwwwwwww w ",
" w w ",
" w f w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
"wwwf w fwwwwwwwwwwwwwwwf w fwww",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w w w ",
" w f w ",
" w w ",
" w wwwwwwwwwwwww w ",
" w w ",
" w f w ",
" wwwwwww w wwwwwww ",
" w ",
" w "
],
"delay": 200,
"snake": [
[16, 4],
[15, 4],
[14, 4]
]
}

View file

@ -90,10 +90,11 @@
} }
}; };
currentGame=snek; currentGame=snek;
//XXX
window.snek=snek;
}); });
window.addEventListener('keydown', async e => { window.addEventListener('keydown', async e => {
e.preventDefault();
if(e.key=='f') { if(e.key=='f') {
if(document.fullscreenElement) await document.exitFullscreen(); if(document.fullscreenElement) await document.exitFullscreen();
else await main.requestFullscreen(); else await main.requestFullscreen();
@ -107,8 +108,7 @@
else if(e.key=='ArrowRight') inputs.right=true; else if(e.key=='ArrowRight') inputs.right=true;
}); });
const handleTouch=e => { window.addEventListener('touchstart', e => {
e.preventDefault();
let x=e.touches[0].clientX/window.innerWidth-.5; let x=e.touches[0].clientX/window.innerWidth-.5;
let y=e.touches[0].clientY/window.innerHeight-.5; let y=e.touches[0].clientY/window.innerHeight-.5;
const angle=((Math.atan2(x, y)+2*Math.PI)%(2*Math.PI))/Math.PI; const angle=((Math.atan2(x, y)+2*Math.PI)%(2*Math.PI))/Math.PI;
@ -118,10 +118,6 @@
else if(angle>.75 && angle<1.25) inputs.up=true; else if(angle>.75 && angle<1.25) inputs.up=true;
else if(angle>1.25 && angle<1.75) inputs.left=true; else if(angle>1.25 && angle<1.75) inputs.left=true;
else inputs.down=true; else inputs.down=true;
});
inputs.clearBuffer=true;
};
window.addEventListener('touchstart', handleTouch);
window.addEventListener('touchmove', handleTouch);
})(); })();

View file

@ -322,12 +322,6 @@ class SnekGame {
else if(inputs.right && trySet([ 1, 0])) return delete inputs.right; else if(inputs.right && trySet([ 1, 0])) return delete inputs.right;
else if(inputs.up && trySet([ 0,-1])) return delete inputs.up; else if(inputs.up && trySet([ 0,-1])) return delete inputs.up;
else if(inputs.down && trySet([ 0, 1])) return delete inputs.down; else if(inputs.down && trySet([ 0, 1])) return delete inputs.down;
if(inputs.clearBuffer) {
Object
.keys(inputs)
.forEach(k => delete inputs[k]);
}
} }
start() { start() {