/** * Add all satellite protections */ void satellites_add (void) { while (num_of_satellites < 5) { satellite_add (); } }
/** * Collision between a gem and the spaceship * @param gem_str pointer to a gem structure * @return TRUE if the gem touched the spaceship */ static bool bonus_collision (const gem_str * const gem) { image *gem_img, *ship_img; Sint32 i; Sint32 collisionx, collisiony, gemx, gemy; spaceship_struct *ship = spaceship_get (); gem_img = gem->img[gem->current_image]; ship_img = ship->spr.img[ship->spr.current_image]; gemx = (Sint32) gem->xcoord + gem_img->collisions_coords[0][XCOORD]; gemy = (Sint32) gem->ycoord + gem_img->collisions_coords[0][YCOORD]; /* for each collision point of the spaceship */ for (i = 0; i < ship_img->numof_collisions_points; i++) { collisionx = (Sint32) ship->spr.xcoord + ship_img->collisions_points[i][XCOORD]; collisiony = (Sint32) ship->spr.ycoord + ship_img->collisions_points[i][YCOORD]; /* check if collision point is into gem collision zone */ if (collisionx >= gemx && collisiony >= gemy && collisionx < (gemx + gem_img->collisions_sizes[0][IMAGE_WIDTH]) && collisiony < (gemy + gem_img->collisions_sizes[0][IMAGE_HEIGHT])) { /* increase score of the player */ player_score += 250 << score_multiplier; switch (gem->type) { /* * add one level in the options range (green gem) */ case BONUS_INC_BY_1: { ship->gems_count++; option_change = TRUE; #ifdef USE_SDLMIXER sound_play (SOUND_GREEN_GEM); #endif } break; /* * add two levels in the options range (red gem) */ case BONUS_INC_BY_2: { ship->gems_count += 2; option_change = TRUE; #ifdef USE_SDLMIXER sound_play (SOUND_RED_GEM); #endif } break; /* * add a satellite protection (yellow gem) */ case BONUS_ADD_SATELLITE: { satellite_add (); #ifdef USE_SDLMIXER sound_play (SOUND_YELLOW_GEM); #endif } break; /* * restore energy level of the spaceship * (purple gem) */ case BONUS_INC_ENERGY: { if (ship->spr.energy_level < ship->spr.pow_of_dest) { option_boxes[1].close_option = FALSE; #ifdef USE_SDLMIXER sound_play (SOUND_PURPLE_GEM); #endif } /* maximum energy level reached: * circular shock wave is propagated */ else { shockwave_add (); } /* increase the level of energy of the spaceship */ ship->spr.energy_level += 20; if (ship->spr.energy_level >= ship->spr.pow_of_dest) { ship->spr.energy_level = ship->spr.pow_of_dest; if (!option_boxes[OPTION_PANEL_REPAIR].close_option) { /* maximum energy level: * start anim of closing option box */ option_anim_init (OPTION_PANEL_REPAIR, TRUE); } } energy_gauge_spaceship_is_update = TRUE; } break; /* * add a score multiplier (blue gem) */ case 4: { score_multiplier++; /* multiplier x4 maximum is allowed */ if (score_multiplier > 2) { score_multiplier = 2; } } break; } return TRUE; } } return FALSE; }