Shoot as bird

Version:

1.0

Added on:

11 Sep 2014 20:59

Tags:

Description:
Rework of this:
http://www.jazz2online.com/snippets/88/player-can-shoot-as-a-bird/
/*bird shoot script*/
/*author: szmol96*/
/**fixed by aya*/

int fireKey = 0;

void CreateBullet(int playerID, float ySpeed)
{
    int bulletID = jjAddObject(OBJECT::BLASTERBULLET, jjPlayers[playerID].xPos, jjPlayers[playerID].yPos, jjPlayers[playerID].playerID, CREATOR::PLAYER);
    jjObjects[bulletID].direction = jjPlayers[playerID].direction;
    jjObjects[bulletID].ySpeed = ySpeed;
    jjObjects[bulletID].xSpeed = (jjObjects[bulletID].direction*10)+p.xSpeed*3;
    jjObjects[bulletID].xAcc = jjObjects[bulletID].direction*5;
}


void onPlayerInput(jjPLAYER@ p)
{
    if(p.charCurr == CHAR::BIRD)
    {
        if(p.keyFire)
        {
            //fastfire
            if(fireKey == 0 || fireKey >= p.fastfire)
            {
                //can't shoot as frozen
                if(p.frozen == 0)
                {
                    CreateBullet(p.playerID, -0.26);
                    CreateBullet(p.playerID, 1.76);
                }
                fireKey = 0;
            }
            ++fireKey;
        }
        else
            fireKey = 0;

        //use run instead of fire key to do that spin
        p.keyFire = false;
        if(p.keyRun)
            p.keyFire = true;
    }
}