$.Math.impactDetection = (obj) => {
let border_top = 0,
border_left = 0,
border_right = $.canvas.width,
border_bottom = $.canvas.height;
let reduce = - $.config.lose
for (let i = 0; i < $.asteroids.length; i++) {
let tag = $.asteroids[i];
if (tag.name == obj.name)
continue;
let dx = Math.pow(obj.x - tag.x, 2);
let dy = Math.pow(obj.y - tag.y, 2);
let d = Math.pow(obj.radius + tag.radius, 2);
if ($.Math.distance(obj, tag) <= 0.1) {
obj.vX = obj.vX * reduce;
obj.vY = obj.vY * reduce;
if (obj.x - tag.x > 0) {
obj.x = Math.abs(Math.sqrt(d - dy) + tag.x) + 2;
} else {
obj.x = tag.x - Math.abs(Math.sqrt(d - dy)) - 2;
}
tag.vX = tag.vX * reduce;
tag.vY = tag.vY * reduce;
}
}
*
回帖描述:*
链接类型:*
下载链接:*
描述:*
回帖描述:*
链接类型:*
阅读权限:*
下载链接:



聚优部落技术论坛 © 版权所有 鲁ICP备15007479号-6
Copyright(C)web.com, All Rights Reserved.
