home *** CD-ROM | disk | FTP | other *** search
- class com.neodelight.v2D.RectSprite extends com.neodelight.v2D.Sprite
- {
- var collisionStyle;
- var wall;
- var ground;
- var cargo;
- var tv;
- var id;
- var v;
- var colPos;
- var carryable;
- var boundingRect;
- var ghost;
- var pos;
- var size;
- var colGhosts;
- var tpos;
- var strong;
- var crusher;
- var fixed;
- var colType;
- var colPartner;
- var flex;
- var colNewVy;
- var colNewVx;
- var colNewPartnerVx;
- var colNewPartnerVy;
- var carrier;
- var collisionCheck70 = com.neodelight.v2D.RectObject.prototype.collisionCheck70;
- var collisionCheck71 = com.neodelight.v2D.RectObject.prototype.collisionCheck71;
- function RectSprite(mc, f, weight, flags, collisionPartners)
- {
- super(mc,f,undefined,flags,collisionPartners,undefined);
- this.collisionStyle = 2;
- this.updateTotalBoundingRect();
- }
- function move()
- {
- this.wall = undefined;
- var _loc5_ = this.ground;
- this.ground = undefined;
- super.move();
- for(var _loc4_ in this.cargo)
- {
- this.cargo[_loc4_].tryPush(new com.neodelight.std.Vector3D(this.tv.x,Math.max(0,this.tv.y),0));
- }
- if(this.ground != _loc5_)
- {
- delete _loc5_.cargo[this.id];
- }
- if(this.ground)
- {
- var _loc6_ = this.tryPush(new com.neodelight.std.Vector3D(this.v.x * _global.dt * (1 - this.colPos),0));
- if(this.ground.carrier && this.carryable)
- {
- this.ground.cargo[this.id] = this;
- }
- }
- if(this.wall)
- {
- _loc6_ = this.tryPush(new com.neodelight.std.Vector3D(0,this.v.y * _global.dt * (1 - this.colPos)));
- if(_loc6_ < 1 && this.v.y < 0)
- {
- this.v.y = 0;
- }
- }
- }
- function tryPush(v)
- {
- var _loc5_ = this.ground;
- var _loc6_ = super.tryPush(v);
- for(var _loc4_ in this.cargo)
- {
- this.cargo[_loc4_].tryPush(new com.neodelight.std.Vector3D(v.x,Math.max(0,v.y),0));
- }
- if(this.ground != _loc5_)
- {
- delete _loc5_.cargo[this.id];
- }
- return _loc6_;
- }
- function collisionCheck2(partner)
- {
- if(this.boundingRect.p0.x <= partner.pos.x + partner.size.x && this.boundingRect.p1.x >= partner.pos.x && this.boundingRect.p0.y <= partner.pos.y + partner.size.y && this.boundingRect.p1.y >= partner.pos.y)
- {
- if(this.ghost || partner.ghost)
- {
- if(this.pos.x <= partner.pos.x + partner.size.x && this.pos.x + this.size.x >= partner.pos.x && this.pos.y <= partner.pos.y + partner.size.y && this.pos.y + this.size.y >= partner.pos.y)
- {
- this.colGhosts.push({pos:scale,obj:partner});
- }
- return undefined;
- }
- if(this.v.x > 0)
- {
- if(Math.round((this.pos.x + this.size.x) * 1000) / 1000 <= Math.round(partner.pos.x * 1000) / 1000 && Math.round((this.tpos.x + this.size.x) * 1000) / 1000 >= Math.round(partner.pos.x * 1000) / 1000)
- {
- var scale = (partner.pos.x - (this.pos.x + this.size.x)) / (this.tpos.x - this.pos.x);
- if(scale <= this.colPos)
- {
- var _loc3_ = Math.round((this.pos.y + scale * (this.tpos.y - this.pos.y) - partner.pos.y) * 1000) / 1000;
- if(_loc3_ < Math.round(partner.size.y * 1000) / 1000 && _loc3_ > Math.round(-1 * this.size.y * 1000) / 1000)
- {
- var _loc5_ = false;
- if(this.strong && !partner.fixed && !partner.ghost)
- {
- var _loc6_ = this.tpos.x + this.size.x - partner.pos.x;
- if(partner.tryPush(new com.neodelight.std.Vector3D(_loc6_,0,0)) < 1)
- {
- if(this.crusher)
- {
- partner.damage(1);
- }
- scale = (partner.pos.x - (this.pos.x + this.size.x)) / (this.tpos.x - this.pos.x);
- _loc5_ = true;
- }
- }
- if(!partner.ghost && !this.ghost && (!this.fixed || _loc5_))
- {
- this.colType = 40;
- this.colPartner = partner;
- this.colPos = scale;
- if(this.flex > 0)
- {
- this.colNewVy = this.v.y * this.flex;
- this.colNewVx = Math.abs(this.v.x) * -1 * this.flex;
- }
- else
- {
- this.colNewVx = 0;
- this.colNewVy = undefined;
- }
- this.colNewPartnerVx = undefined;
- this.colNewPartnerVy = undefined;
- this.wall = partner;
- }
- else
- {
- this.colGhosts.push({pos:scale,obj:partner});
- }
- }
- }
- }
- }
- else if(this.v.x < 0)
- {
- if(Math.round(this.pos.x * 1000) / 1000 >= Math.round((partner.pos.x + partner.size.x) * 1000) / 1000 && Math.round(this.tpos.x * 1000) / 1000 < Math.round((partner.pos.x + partner.size.x) * 1000) / 1000)
- {
- var scale = (partner.pos.x + partner.size.x - this.pos.x) / (this.tpos.x - this.pos.x);
- if(scale < this.colPos)
- {
- _loc3_ = Math.round((this.pos.y + scale * (this.tpos.y - this.pos.y) - partner.pos.y) * 1000) / 1000;
- if(_loc3_ < Math.round(partner.size.y * 1000) / 1000 && _loc3_ > Math.round(-1 * this.size.y * 1000) / 1000)
- {
- _loc5_ = false;
- if(this.strong && !partner.fixed && !partner.ghost)
- {
- _loc6_ = this.tpos.x - (partner.pos.x + partner.size.x);
- if(partner.tryPush(new com.neodelight.std.Vector3D(_loc6_,0,0)) < 1)
- {
- if(this.crusher)
- {
- partner.damage(1);
- }
- scale = (partner.pos.x + partner.size.x - this.pos.x) / (this.tpos.x - this.pos.x);
- _loc5_ = true;
- }
- }
- if(!partner.ghost && !this.ghost && (!this.fixed || _loc5_))
- {
- this.colType = 41;
- this.colPartner = partner;
- this.colPos = scale;
- if(this.flex > 0)
- {
- this.colNewVy = this.v.y * this.flex;
- this.colNewVx = Math.abs(this.v.x) * this.flex;
- }
- else
- {
- this.colNewVx = 0;
- this.colNewVy = undefined;
- }
- this.colNewPartnerVx = undefined;
- this.colNewPartnerVy = undefined;
- this.wall = partner;
- }
- else
- {
- this.colGhosts.push({pos:scale,obj:partner});
- }
- }
- }
- }
- }
- if(this.v.y > 0)
- {
- if(Math.round((this.pos.y + this.size.y) * 1000) / 1000 <= Math.round(partner.pos.y * 1000) / 1000 && Math.round((this.tpos.y + this.size.y) * 1000) / 1000 >= Math.round(partner.pos.y * 1000) / 1000)
- {
- var scale = (partner.pos.y - (this.pos.y + this.size.y)) / (this.tpos.y - this.pos.y);
- if(scale <= this.colPos)
- {
- var _loc4_ = Math.round((this.pos.x + scale * (this.tpos.x - this.pos.x) - partner.pos.x) * 1000) / 1000;
- if(_loc4_ < Math.round(partner.size.x * 1000) / 1000 && _loc4_ > Math.round(-1 * this.size.x * 1000) / 1000)
- {
- _loc5_ = false;
- if(this.strong && !partner.fixed && !partner.ghost)
- {
- _loc6_ = this.tpos.y + this.size.y - partner.pos.y;
- if(partner.tryPush(new com.neodelight.std.Vector3D(0,_loc6_,0)) < 1)
- {
- if(this.crusher)
- {
- partner.damage(1);
- }
- scale = (partner.pos.y - (this.pos.y + this.size.y)) / (this.tpos.y - this.pos.y);
- _loc5_ = true;
- }
- }
- if(!partner.ghost && !this.ghost && (!this.fixed || _loc5_))
- {
- this.colType = 30;
- this.colPartner = partner;
- this.colPos = scale;
- if(this.flex > 0)
- {
- this.colNewVy = Math.abs(this.v.y) * -1 * this.flex;
- this.colNewVx = this.v.x * this.flex;
- }
- else
- {
- this.colNewVx = undefined;
- this.colNewVy = 0;
- }
- this.colNewPartnerVx = undefined;
- this.colNewPartnerVy = undefined;
- this.ground = partner;
- }
- else
- {
- this.colGhosts.push({pos:scale,obj:partner});
- }
- }
- }
- }
- }
- else if(this.v.y < 0)
- {
- if(Math.round(this.pos.y * 1000) / 1000 >= Math.round((partner.pos.y + partner.size.y) * 1000) / 1000 && Math.round(this.tpos.y * 1000) / 1000 < Math.round((partner.pos.y + partner.size.y) * 1000) / 1000)
- {
- var scale = (partner.pos.y + partner.size.y - this.pos.y) / (this.tpos.y - this.pos.y);
- if(scale < this.colPos)
- {
- _loc4_ = Math.round((this.pos.x + scale * (this.tpos.x - this.pos.x) - partner.pos.x) * 1000) / 1000;
- if(_loc4_ < Math.round(partner.size.x * 1000) / 1000 && _loc4_ > Math.round(-1 * this.size.x * 1000) / 1000)
- {
- _loc5_ = false;
- if(this.strong && !partner.fixed && !partner.ghost)
- {
- if(this.carrier && partner.carryable)
- {
- delete partner.ground.cargo[partner.id];
- partner.ground = this;
- this.cargo[partner.id] = partner;
- }
- _loc6_ = this.tpos.y - partner.size.y - partner.pos.y;
- if(partner.tryPush(new com.neodelight.std.Vector3D(0,_loc6_,0)) < 1)
- {
- if(this.crusher)
- {
- partner.damage(1);
- }
- scale = (partner.pos.y + partner.size.y - this.pos.y) / (this.tpos.y - this.pos.y);
- _loc5_ = true;
- }
- }
- if(!partner.ghost && !this.ghost && (!this.fixed || _loc5_))
- {
- this.colType = 2;
- this.colPartner = partner;
- this.colPos = scale;
- if(this.flex > 0)
- {
- this.colNewVy = Math.abs(this.v.y) * this.flex;
- this.colNewVx = this.v.x * this.flex;
- }
- else
- {
- this.colNewVx = undefined;
- this.colNewVy = 0;
- }
- this.colNewPartnerVx = undefined;
- this.colNewPartnerVy = undefined;
- }
- else
- {
- this.colGhosts.push({pos:scale,obj:partner});
- }
- }
- }
- }
- }
- }
- }
- function collisionCheck30(partner)
- {
- if(this.v.y <= 0)
- {
- return undefined;
- }
- if(Math.round((this.pos.y + this.size.y) * 1000) / 1000 <= Math.round(partner.pos.y * 1000) / 1000 && Math.round((this.tpos.y + this.size.y) * 1000) / 1000 > Math.round(partner.pos.y * 1000) / 1000)
- {
- var _loc3_ = (partner.pos.y - (this.pos.y + this.size.y)) / (this.tpos.y - this.pos.y);
- if(_loc3_ <= this.colPos)
- {
- var _loc4_ = this.pos.x + _loc3_ * (this.tpos.x - this.pos.x) - partner.pos.x;
- if(_loc4_ <= partner.size.x && _loc4_ >= -1 * this.size.x)
- {
- this.colPos = _loc3_;
- this.colType = partner.collisionStyle;
- this.colPartner = partner;
- if(this.flex > 0)
- {
- this.colNewVy = Math.abs(this.v.y) * -1 * this.flex;
- this.colNewVx = this.v.x * this.flex;
- }
- else
- {
- this.colNewVx = undefined;
- this.colNewVy = 0;
- }
- this.colNewPartnerVx = undefined;
- this.colNewPartnerVy = undefined;
- this.ground = partner;
- }
- }
- }
- }
- function collisionCheck5(partner)
- {
- }
- function getBoundingRect()
- {
- this.boundingRect.p0.x = Math.min(this.pos.x,this.tpos.x);
- this.boundingRect.p0.y = Math.min(this.pos.y,this.tpos.y);
- this.boundingRect.p1.x = Math.max(this.pos.x,this.tpos.x) + this.size.x;
- this.boundingRect.p1.y = Math.max(this.pos.y,this.tpos.y) + this.size.y;
- return this.boundingRect;
- }
- }
-