fixed engine to limit input buffering in time
This commit is contained in:
parent
de390dff8a
commit
10585fef98
1 changed files with 14 additions and 1 deletions
|
@ -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