Guest User

Untitled

a guest
Mar 1st, 2013
62
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                 keyStack: [],
  2.                 /******************************************8
  3.                  * Update
  4.                  ******************************************/
  5.                 update: function()
  6.                 {
  7.  
  8.                     // remove all keys from the stack that are not being held down anymore
  9.                     for( var i = this.keyStack.length; i--; ) {
  10.                         if( !ig.input.state(this.keyStack[i]) ) {
  11.                             this.keyStack.splice(i, 1);
  12.                         }
  13.                     }
  14.                     var idleSpeed = 120;
  15.                     var fastSpeed = 150;
  16.                     var backSpeed = 80;
  17.  
  18.                     if( ig.input.state('upArrow') ){
  19.                         this.keyStack.push('upArrow');
  20.                     }
  21.                     else if ( ig.input.state('downArrow') ){
  22.                         this.keyStack.push('downArrow');
  23.                     }
  24.                     if( ig.input.state('leftArrow') ){
  25.                         this.keyStack.push('leftArrow');
  26.                     }
  27.                     else if( ig.input.state('rightArrow') ){
  28.                         this.keyStack.push('rightArrow');
  29.                     }
  30.                     else{
  31.                        this.vel.x = idleSpeed;
  32.                        this.currentAnim = this.anims.idle;
  33.                         this.lastKey = 'shoot';
  34.                     }
  35.  
  36.                     // get the key from the top of the stack
  37.                     var lastKey = this.keyStack[this.keyStack.length-1];
  38.  
  39.  
  40.  
  41.                    switch (lastKey)
  42.                     {
  43.                         case 'shoot':
  44.                              ig.game.spawnEntity(EntityBullet, this.pos.x + 44, this.pos.y +5,          {flip:this.flip});
  45.                              break;
  46.  
  47.                         case 'upArrow':
  48.                             this.vel.y = -idleSpeed;
  49.                             this.accel.x = this.speed;
  50.                             this.currentAnim = this.anims.bankLeft;
  51.                             break;
  52.  
  53.                         case 'downArrow:':
  54.                             this.vel.y = idleSpeed;
  55.                             this.accel.x = this.speed;
  56.                             this.currentAnim = this.anims.bankRight;
  57.                             break;
  58.  
  59.                         case 'leftArrow':
  60.                             this.vel.x = backSpeed;
  61.                             break;
  62.  
  63.                         case 'rightArrow':
  64.                             this.vel.x = fastSpeed;
  65.                             break;
RAW Paste Data