示例#1
0
void crashPlayer(int player) {
  int j;

#ifdef SOUND
  playCrashSound(0, player);
#endif

  for(j = 0; j < game->players; j++) 
    if(j != player && game->player[j].data->speed > 0)
      game->player[j].data->score++;

  game->player[player].data->speed = SPEED_CRASHED;

  if(game2->rules.eraseCrashed == 1)
    clearTrail(player);
}
示例#2
0
/*Check whether any collisions occurred.*/
void checkForCollisions()
{
    struct vertex center = {0.0, 0.0, 0.0};
  
    for(int i = 0; i < globalProjectile.pIndex; i++)
    {
        struct vertex projPos = globalProjectile.projectiles[i].position;

        checkBaseCollisions(globalProjectile.projectiles[i], i);
       
        /*Test for outer ring collision. Negate the collision result 
         *to get when the sum of the radii is less than the distance.*/
        if(!isCollision(projPos, center, RADIUS, RING_SIZE))
            handleCollision(i);

        /*Test sun collision.*/
        if(isCollision(projPos, center, RADIUS, RADIUS))
            handleCollision(i);

        /*Test for sail collision.*/
        if(isSailCollision(projPos, center))
            handleCollision(i);

        /*Test if this projectile colllided with another projectile.*/
        int collided = projectileCollided(projPos, i);
        if(collided != NO_COLLISION)
        {
            printf("Got a collision! Proj:%d\n", i);
            deleteProjectile(i);
            /*Subtract 1 as the previously deleted projectile
             *will move the array one step to the left.*/
            deleteProjectile(collided - 1);
            playCrashSound();
        }
    }
}
示例#3
0
/*If a collision occured, call this function to handle it.*/
void handleCollision(int i)
{
    //printf("Got a collision! Proj:%d\n", i);
    deleteProjectile(i);
    playCrashSound();
}