I have a function that will either not enter or not complete correctly. Since I am using allegro and it takes control of the screen I havent been able to debug to see what's wrong. I have tried everything, and my function call seems fine the way it is. Hopefully someone can see what is wrong. I'll just include the function and the call, but if anyone wants the entire file I'll post the project file.
Code:
//structures used
struct person{
int x,y; //point coords
int width, height; //sprite dimensions
float x_vel, y_vel; //velocities
int alive; //alive, dead, or dying
int direction; //facing left or right
BITMAP *sprite; //pointer to current sprite
};
struct bullet{
int x,y; //point coords
int width, height; //sprite dimensions
float vel; //velocity for x-dimension
bool exists; //is bullet fired or not
int num_bullets; //number of bullets in array, to help functions
};
//function
bool fire_bullet(struct person *shooter,struct bullet ammo[])
{
int count=0;
for(count=0;count < ammo->num_bullets;count++)
{
if(ammo[count].exists == false)
{
ammo[count].exists=true;
if(shooter->direction == LEFT)
{
ammo[count].x=shooter->x;
ammo[count].vel= -BULLET_VEL;
}
else
{
ammo[count].x=shooter->x + shooter->width;
ammo[count].vel=BULLET_VEL;
}
ammo[count].y=shooter->y;
return true;
}
}
return false;
}
END_OF_FUNCTION(fire_bullet);
//function call
if(key[KEY_ENTER])
fire_bullet(&player,player_bullets);