Compare commits
3 commits
de390dff8a
...
6b7ff7e86d
Author | SHA1 | Date | |
---|---|---|---|
6b7ff7e86d | |||
1df62ff1fe | |||
10585fef98 |
4 changed files with 46 additions and 2 deletions
|
@ -8,9 +8,11 @@
|
|||
[16, 10]
|
||||
],
|
||||
"rules": {
|
||||
"worldWrap": false,
|
||||
"autoSpeedIncrease": true,
|
||||
"autoSpeadIncreaseTicks": 10,
|
||||
"autoSizeGrow": true,
|
||||
"autoSizeGrowTicks": 100
|
||||
"autoSizeGrowTicks": 100,
|
||||
"scoreSystem": "survival"
|
||||
}
|
||||
}
|
||||
|
|
17
levels/arcade-timed.json
Normal file
17
levels/arcade-timed.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"dimensions": [32, 32],
|
||||
"delay": 100,
|
||||
"food": [
|
||||
[16, 5]
|
||||
],
|
||||
"snake": [
|
||||
[16, 12],
|
||||
[16, 11],
|
||||
[16, 10]
|
||||
],
|
||||
"rules": {
|
||||
"speedMultiplier": 0.8,
|
||||
"gameDuration": 30000,
|
||||
"winCondition": "time"
|
||||
}
|
||||
}
|
|
@ -108,4 +108,16 @@
|
|||
else if(e.key=='ArrowRight') inputs.right=true;
|
||||
});
|
||||
|
||||
window.addEventListener('touchstart', e => {
|
||||
let x=e.touches[0].clientX/window.innerWidth-.5;
|
||||
let y=e.touches[0].clientY/window.innerHeight-.5;
|
||||
const angle=((Math.atan2(x, y)+2*Math.PI)%(2*Math.PI))/Math.PI;
|
||||
|
||||
let inputs=currentInputs;
|
||||
if(angle>.25 && angle <.75) inputs.right=true;
|
||||
else if(angle>.75 && angle<1.25) inputs.up=true;
|
||||
else if(angle>1.25 && angle<1.75) inputs.left=true;
|
||||
else inputs.down=true;
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
|
@ -82,7 +82,9 @@ class SnekGame {
|
|||
worldWrap: true,
|
||||
winCondition: 'none',
|
||||
scoreSystem: 'fruit',
|
||||
netPlay: false
|
||||
netPlay: false,
|
||||
autoSizeGrow: false,
|
||||
autoSpeedIncrease: false
|
||||
}, rules, settings.rules || {});
|
||||
}
|
||||
|
||||
|
@ -305,6 +307,17 @@ class SnekGame {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Object
|
||||
.keys(inputs)
|
||||
.forEach(k => {
|
||||
let v=inputs[k];
|
||||
if(v===true) v=5;
|
||||
v--;
|
||||
if(!v) delete inputs[k];
|
||||
else inputs[k]=v;
|
||||
});
|
||||
|
||||
if(inputs.left && trySet([-1, 0])) return delete inputs.left;
|
||||
else if(inputs.right && trySet([ 1, 0])) return delete inputs.right;
|
||||
else if(inputs.up && trySet([ 0,-1])) return delete inputs.up;
|
||||
|
|
Loading…
Reference in a new issue