/**
* 矩形区域碰撞检测
* Created by Administrator on 14-4-7.
* author: marker
*/
function Rectangle(x, y, _width, _height){
this.x = x;
this.y = y;
this.width = _width;
this.height = _height;
//碰撞检测(参数为此类)
this.intersects = function(obj){
var a_x_w = Math.abs((this.x+this.width/2) - (obj.x+obj.width/2));
var b_w_w = Math.abs((this.width+obj.width)/2);
var a_y_h = Math.abs((this.y+this.height/2) - (obj.y+obj.height/2));
var b_h_h = Math.abs((this.height+obj.height)/2);
if( a_x_w < b_w_w && a_y_h < b_h_h ) return true;
else return false;
}
}
/**
* 圆形区域碰撞检测
* Created by Administrator on 14-4-7.
* author: marker
*
*/
function RadiusRectangle(x, y, radius){
this.x = x;
this.y = y;
this.radius = radius;
//碰撞检测(参数为此类)
this.intersects = function(rr){
var maxRadius = rr.radius + this.radius;
// 已知两条直角边的长度 ,可按公式:c²=a²+b² 计算斜边。
var a = Math.abs(rr.x - this.x);
var b = Math.abs(rr.y - this.y);
var distance = Math.sqrt(Math.pow(a,2) + Math.pow(b,2));// 计算圆心距离
if(distance < maxRadius){
return true;
}
return false;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有