"""respond to ship being hit by alien ""decrement ships_left stats ships_left - empty the list of aliens and bullets aliens empty(bullets empty( create new fleet and center the ship create_fleet(ai_settingsscreenshipaliensship center_ship( pause sleep( def update_aliens(ai_settingsstatsscreenshipaliensbullets)--snip-look for alien-ship collisions if pygame sprite spritecollideany(shipaliens)ship_hit(ai_settingsstatsscreenshipaliensbulletswe first import the sleep(function from the time module to pause the game the new function ship_hit(coordinates the response when the ship is hit by an alien inside ship_hit()the number of ships left is reduced by vafter which we empty the groups aliens and bullets nextwe create new fleet and center the ship (we'll add the method center_ship(to ship in moment finallywe pause after the updates have been made to all the game elements but before any changes have been drawn to the screen so the player can see that their ship has been hit the screen will freeze momentarilyand the player will see that the alien has hit the ship when the sleep(function endsthe code will move on to the update_screen(functionwhich will draw the new fleet to the screen we also update the definition of update_aliens(to include the parameters statsscreenand bullets so it can pass these values in the call to ship_hit(here' the new method center_ship()add it to the end of ship pyship py def center_ship(self)"""center the ship on the screen ""self center self screen_rect centerx to center the shipwe set the value of the ship' center attribute to match the center of the screenwhich we get through the screen_rect attribute note notice that we never make more than one shipwe make only one ship instance for the whole game and recenter it whenever the ship has been hit the statistic ships_left will tell us when the player has run out of ships aliens