home *** CD-ROM | disk | FTP | other *** search
- class org.cove.flade.surfaces.MoveRectangleTile extends org.cove.flade.surfaces.RectangleTile implements org.cove.flade.surfaces.Surface
- {
- var MoveCurr;
- var MovePrev;
- var MoveAspect;
- var Moveang;
- var HighShowTime;
- var facedmc;
- var center;
- var rectWidth;
- var rectHeight;
- var timeLastContact;
- var normal;
- function MoveRectangleTile(cx, cy, rw, rh, rootmc, dmc)
- {
- super(cx,cy,rw,rh,rootmc);
- this.MoveCurr = new org.cove.flade.util.Vector(0,0);
- this.MovePrev = new org.cove.flade.util.Vector(0,0);
- this.MoveAspect = true;
- this.Moveang = this.HighShowTime = 0;
- if(dmc != undefined)
- {
- this.facedmc = dmc;
- }
- }
- function MoveLeft(mox)
- {
- this.center.x -= mox;
- this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
- this.MovePrev.x = this.MoveCurr.x;
- this.MoveCurr.x -= mox;
- }
- function MoveRight(mox)
- {
- this.center.x += mox;
- this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
- this.MovePrev.x = this.MoveCurr.x;
- this.MoveCurr.x += mox;
- }
- function MoveUp(moy)
- {
- this.center.y -= moy;
- this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
- this.MovePrev.y = this.MoveCurr.y;
- this.MoveCurr.y -= moy;
- }
- function MoveDown(moy)
- {
- this.center.y += moy;
- this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
- this.MovePrev.y = this.MoveCurr.y;
- this.MoveCurr.y += moy;
- }
- function ReSet(newx, newy)
- {
- this.center.x = newx;
- this.center.y = newy;
- this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
- this.MovePrev.x = this.MoveCurr.x;
- this.MoveCurr.x = this.center.x;
- this.MovePrev.y = this.MoveCurr.y;
- this.MoveCurr.y = this.center.y;
- }
- function MoveHide()
- {
- if(this.getVisible())
- {
- this.setVisible(false);
- this.ReCreateBoundingRect(0,0);
- this.onMoveHide();
- }
- }
- function MovieAgreement()
- {
- this.facedmc._x = this.center.x;
- this.facedmc._y = this.center.y;
- }
- function MoveShow()
- {
- if(!this.getVisible())
- {
- this.setVisible(true);
- this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
- this.onMoveShow();
- }
- }
- function SetMoveAspect(b)
- {
- this.MoveAspect = b;
- }
- function RunLeftRight(mlx, mrx, speed)
- {
- if(this.MoveCurr.x > mrx)
- {
- this.MoveAspect = false;
- }
- if(this.MoveCurr.x < - mlx)
- {
- this.MoveAspect = true;
- }
- if(this.MoveAspect)
- {
- this.MoveRight(speed);
- }
- else
- {
- this.MoveLeft(speed);
- }
- this.MovieAgreement();
- }
- function RunUpDown(muy, mdy, speed)
- {
- if(this.MoveCurr.y > mdy)
- {
- this.MoveAspect = false;
- }
- if(this.MoveCurr.y < - muy)
- {
- this.MoveAspect = true;
- }
- if(this.MoveAspect)
- {
- this.MoveDown(speed);
- }
- else
- {
- this.MoveUp(speed);
- }
- this.MovieAgreement();
- }
- function RunCircle(Runright, r, speed, StartAng)
- {
- if(Runright)
- {
- this.Moveang += 3.141592653589793 * speed / 360;
- }
- else
- {
- this.Moveang -= 3.141592653589793 * speed / 360;
- }
- var _loc3_ = Math.cos(this.Moveang + StartAng) * r;
- var _loc2_ = Math.sin(this.Moveang + StartAng) * r;
- if(_loc3_ > 0)
- {
- this.MoveRight(_loc3_);
- }
- else
- {
- this.MoveLeft(- _loc3_);
- }
- if(_loc2_ > 0)
- {
- this.MoveDown(_loc2_);
- }
- else
- {
- this.MoveUp(- _loc2_);
- }
- this.MovieAgreement();
- }
- function StartRunHide()
- {
- this.timeLastContact = new Date().getTime();
- if(!this.MoveAspect)
- {
- this.HighShowTime = 0;
- this.MoveAspect = true;
- }
- }
- function RunHide(ShowTime, HideTime)
- {
- if(this.MoveAspect)
- {
- if(this.HighShowTime < ShowTime)
- {
- this.MoveShow();
- if(new Date().getTime() - this.timeLastContact > 400)
- {
- this.MoveShow();
- this.HighShowTime = 0;
- this.MoveAspect = false;
- }
- }
- else if(this.HighShowTime < ShowTime + HideTime)
- {
- this.MoveHide();
- }
- else if(this.HighShowTime > ShowTime + HideTime)
- {
- this.MoveAspect = false;
- this.MoveShow();
- this.HighShowTime = 0;
- }
- this.HighShowTime = this.HighShowTime + 1;
- }
- }
- function resolveCircleCollision(p, sysObj)
- {
- if(this.isCircleColliding(p))
- {
- this.onContact();
- p.resolveCollision(this.normal,sysObj);
- p.SetCollision();
- p.curr.x += this.MoveCurr.x - this.MovePrev.x;
- p.prev.x += this.MoveCurr.x - this.MovePrev.x;
- }
- }
- function onMoveHide()
- {
- }
- function onMoveShow()
- {
- }
- function GetCenterY()
- {
- return this.center.y;
- }
- }
-