1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
unsigned long* collisionhandler::checkpellethit(int good, int *n)
{
int z=0;
unsigned long *dead = new unsigned long[weapons.size()];
int q = weapons.size();
for (int i=0;i<q;i++)
{
//printf("in collisionhandler, checkpellethit\n");
if(weapons[i].type==3)
{
int r = players.size();
for(int j=0;j<r;j++)
{
if(players[j].good!=good)
{
playerarea[!good]->setarea(players[j].x,players[j].y,players[j].theta);
shotguns[good]->setarea(weapons[i].x,weapons[i].y,weapons[i].theta);
fprintf(stdout,"pellet: x: %f, y: %f, good: %i. player: x: %f, y: %f, good: %i\n",weapons[i].x, weapons[i].y, weapons[i].good, players[j].x, players[j].y, players[j].good);
if (playerarea[!good]->didhit(*shotguns[good]))
{
printf("Killed\n");
dead[z]=weapons[i].idd;
weapons.erase(weapons.begin()+i);
player a = players[j];
players.erase(players.begin()+j);
a.hit=1;
players.push_back(a);
z++;
}
}
}
}
}
*n=z;
return dead;
}
|