nio_kasgami

messy method

Nov 16th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Game_AI.prototype.executeSlideHorizontaly = function(a,b) {
  2.     // a = speed
  3.     // b = total time
  4.     var initialPos = -400;
  5.     var finalPos = this._personality.xOffset;
  6.     this._value = 0;
  7. // begin loop
  8.     if(this._value < b ){
  9.         this._value ++
  10.     // first condition : if x is inferior than the finalPos
  11.         if(this.aiSprite.x < finalPos){
  12.             this.aiSprite.x += a;
  13.         // second condition : if value is reaching is limit
  14.          if(this._value >= b){
  15.           this.aiSprite.x = finalPos;
  16.          }
  17.         }
  18.     // third condition : if the x = finalPos AND time value is not b
  19.     // return the sprite to his initiat position if asked.
  20.         if(this.aiSprite.x >= finalPos && !this._value >= b){
  21.             this.aiSprite.x -= a;
  22.         // last condition : if the pose is inferior or equal to initial pos
  23.         // or time limit is reached.
  24.             if(this.aiSprite.x <= initialPos || this._value >= b){
  25.                 this.aiSprite.x = initialPos;
  26.             }
  27.         }
  28.     }
  29. // deactivate the flag when finish
  30.     this.setEffectFlag(false);
  31. };
Advertisement
Add Comment
Please, Sign In to add comment