Shoot as bird

Version:

1.0

Added on:

11 Sep 2014 22:59

Tags:

Description:
Rework of this:
http://www.jazz2online.com/snippets/88/player-can-shoot-as-a-bird/
  1. /*bird shoot script*/
  2. /*author: szmol96*/
  3. /**fixed by aya*/
  4.  
  5. int fireKey = 0;
  6.  
  7. void CreateBullet(int playerID, float ySpeed)
  8. {
  9.     int bulletID = jjAddObject(OBJECT::BLASTERBULLET, jjPlayers[playerID].xPos, jjPlayers[playerID].yPos, jjPlayers[playerID].playerID, CREATOR::PLAYER);
  10.     jjObjects[bulletID].direction = jjPlayers[playerID].direction;
  11.     jjObjects[bulletID].ySpeed = ySpeed;
  12.     jjObjects[bulletID].xSpeed = (jjObjects[bulletID].direction*10)+p.xSpeed*3;
  13.     jjObjects[bulletID].xAcc = jjObjects[bulletID].direction*5;
  14. }
  15.  
  16.  
  17. void onPlayerInput(jjPLAYER@ p)
  18. {
  19.     if(p.charCurr == CHAR::BIRD)
  20.     {
  21.         if(p.keyFire)
  22.         {
  23.             //fastfire
  24.             if(fireKey == 0 || fireKey >= p.fastfire)
  25.             {
  26.                 //can't shoot as frozen
  27.                 if(p.frozen == 0)
  28.                 {
  29.                     CreateBullet(p.playerID, -0.26);
  30.                     CreateBullet(p.playerID, 1.76);
  31.                 }
  32.                 fireKey = 0;
  33.             }
  34.             ++fireKey;
  35.         }
  36.         else
  37.             fireKey = 0;
  38.  
  39.         //use run instead of fire key to do that spin
  40.         p.keyFire = false;
  41.         if(p.keyRun)
  42.             p.keyFire = true;
  43.     }
  44. }