Guest User

Untitled

a guest
Mar 1st, 2013
43
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                 /******************************************8
  2.                  * Update
  3.                  ******************************************/
  4.                 update: function()
  5.                 {
  6.                     var idleSpeed = 120;
  7.                     var fastSpeed = 150;
  8.                     var backSpeed = 80;
  9.  
  10.                     if( ig.input.state('upArrow') ){
  11.                         this.vel.y = -idleSpeed;
  12.                         this.accel.x = this.speed;
  13.                         this.currentAnim = this.anims.bankLeft;
  14.                     }
  15.                     else if ( ig.input.state('downArrow') ){
  16.                         this.vel.y = idleSpeed;
  17.                         this.accel.x = this.speed;
  18.                         this.currentAnim = this.anims.bankRight;
  19.                     }
  20.                     if( ig.input.state('leftArrow') ){
  21.                         this.vel.x = backSpeed;
  22.                     }
  23.                     else if( ig.input.state('rightArrow') ){
  24.                         this.vel.x = fastSpeed;
  25.                     }
  26.                     else{
  27.                         this.vel.x = idleSpeed;
  28.                         this.currentAnim = this.anims.idle;
  29.                     }
  30.  
  31.                     // set the current animation, based on the player's speed
  32.                     //upArrow
  33.                     if( this.vel.y < 0 ) {
  34.                         this.currentAnim = this.anims.bankLeft;
  35.                         //downArrow
  36.                     }else if( this.vel.y > 20 ) {
  37.                         this.currentAnim = this.anims.bankRight;
  38.                     }else if (this.vel.y = 0){
  39.                         this.currentAnim = this.anims.idle
  40.                     }
  41.                     else if( this.vel.x > idleSpeed ) {
  42.                         //rightArrow
  43.                         this.currentAnim = this.anims.speedBurst;
  44.                     }else if(this.vel.x > idleSpeed){
  45.                         //leftArrow
  46.                         this.currentanim = this.anims.moveBack;
  47.                     }else{
  48.                         this.currentAnim = this.anims.idle;
  49.                     }
  50.  
  51.                     this.currentAnim.flip.x = this.flip;
  52.  
  53.                     // Shooting
  54.                     var isShooting = ig.input.state('shoot');
  55.                     if (isShooting && this.lastShootTimer.delta() > 0) {
  56.                         ig.game.spawnEntity(EntityBullet, this.pos.x + 44, this.pos.y +5, {flip:this.flip});
  57.                         this.lastShootTimer.set(0.09);
  58.                     }
  59.                     if (isShooting && !this.wasShooting) {
  60.                         this.wasShooting = true;
  61.  
  62.                     }
  63.                      else if (this.wasShooting && !isShooting) {
  64.                         this.wasShooting = false;
  65.                     }
  66.                     // Movement
  67.                     this.parent();
  68.                 },
RAW Paste Data