You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.
hello, first of all, i'm really like your superior script :)
the lag happen when there are many snake on screen, and the loop handle too muck for ..loop, this cause client lag while running script, i'think you could put it into a worker thread, and your script only handle event from worker, i saw some where this script
var blob = new Blob([
"onmessage = function(e) { postMessage('msg from worker'); }"]);
// Obtain a blob URL reference to our worker 'file'.
var blobURL = window.URL.createObjectURL(blob);
var worker = new Worker(blobURL);
worker.onmessage = function(e) {
// e.data == 'msg from worker'
};
worker.postMessage(); // Start the worker.
Doest is possible to make your script run in thread ?
and another issue is setTimeout,setInterval function, i think window.requestAnimationFrame is better, what do you think ?
window.requestAnimFrame = (function(callback) {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000 / bot.opt.targetFps);
};
})();
and a small piece of code check colision between snakes:
from line 617:
canvasUtil.getDistance2FromSnake(collisionPoint);
bot.addCollisionAngle(collisionPoint);
this is the colision of bone object, a safe colision will be side of bot snake face to, do i wrong ?
if (scPoint === undefined ||
scPoint.distance > collisionPoint.distance-collisionPoint.radius-bot.snakeRadius) {
scPoint = collisionPoint;
}
The text was updated successfully, but these errors were encountered:
hello, first of all, i'm really like your superior script :)
the lag happen when there are many snake on screen, and the loop handle too muck for ..loop, this cause client lag while running script, i'think you could put it into a worker thread, and your script only handle event from worker, i saw some where this script
var blob = new Blob([
"onmessage = function(e) { postMessage('msg from worker'); }"]);
// Obtain a blob URL reference to our worker 'file'.
var blobURL = window.URL.createObjectURL(blob);
var worker = new Worker(blobURL);
worker.onmessage = function(e) {
// e.data == 'msg from worker'
};
worker.postMessage(); // Start the worker.
Doest is possible to make your script run in thread ?
and another issue is setTimeout,setInterval function, i think window.requestAnimationFrame is better, what do you think ?
window.requestAnimFrame = (function(callback) {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000 / bot.opt.targetFps);
};
})();
and a small piece of code check colision between snakes:
from line 617:
canvasUtil.getDistance2FromSnake(collisionPoint);
bot.addCollisionAngle(collisionPoint);
this is the colision of bone object, a safe colision will be side of bot snake face to, do i wrong ?
if (scPoint === undefined ||
scPoint.distance > collisionPoint.distance-collisionPoint.radius-bot.snakeRadius) {
scPoint = collisionPoint;
}
The text was updated successfully, but these errors were encountered: