def checkCrash(player, upperPipes, lowerPipes):
 pi = player['index']
 player['w'] = IMAGES['player'][0].get_width()
 player['h'] = IMAGES['player'][0].get_height()
 if ((player['y'] + player['h']) >= (BASEY - 1)):
  return True
 else:
  playerRect = pygame.Rect(player['x'], player['y'], player['w'], player['h'])
  for (uPipe, lPipe) in zip(upperPipes, lowerPipes):
   uPipeRect = pygame.Rect(uPipe['x'], uPipe['y'], PIPE_WIDTH, PIPE_HEIGHT)
   lPipeRect = pygame.Rect(lPipe['x'], lPipe['y'], PIPE_WIDTH, PIPE_HEIGHT)
   pHitMask = HITMASKS['player'][pi]
   uHitmask = HITMASKS['pipe'][0]
   lHitmask = HITMASKS['pipe'][1]
   uCollide = pixelCollision(playerRect, uPipeRect, pHitMask, uHitmask)
   lCollide = pixelCollision(playerRect, lPipeRect, pHitMask, lHitmask)
   if (uCollide or lCollide):
    return True
 return False

def checkCrash ( player , upperPipes , lowerPipes ) : pi = player [ 'index' ] player [ 'w' ] = IMAGES [ 'player' ] [ 0 ] . get_width ( ) player [ 'h' ] = IMAGES [ 'player' ] [ 0 ] . get_height ( ) if ( ( player [ 'y' ] + player [ 'h' ] ) >= ( BASEY - 1 ) ) : return True else : playerRect = pygame . Rect ( player [ 'x' ] , player [ 'y' ] , player [ 'w' ] , player [ 'h' ] ) for ( uPipe , lPipe ) in zip ( upperPipes , lowerPipes ) : uPipeRect = pygame . Rect ( uPipe [ 'x' ] , uPipe [ 'y' ] , PIPE_WIDTH , PIPE_HEIGHT ) lPipeRect = pygame . Rect ( lPipe [ 'x' ] , lPipe [ 'y' ] , PIPE_WIDTH , PIPE_HEIGHT ) pHitMask = HITMASKS [ 'player' ] [ pi ] uHitmask = HITMASKS [ 'pipe' ] [ 0 ] lHitmask = HITMASKS [ 'pipe' ] [ 1 ] uCollide = pixelCollision ( playerRect , uPipeRect , pHitMask , uHitmask ) lCollide = pixelCollision ( playerRect , lPipeRect , pHitMask , lHitmask ) if ( uCollide or lCollide ) : return True return False
returns true if player collders with base or pipes .