title: Text not being drawn with pygame
body: <p>Alright so i have this function to create a text line that pops up when someone wins the game. The problem I'm having is that it just doesn't show up no matter what I do. The other problem is that I followed a tutorial on youtube and created a game that has the same exact thing but now it's not working in the code I created myself and I'm not sure what I'm doing wrong.</p>
  <p>My code</p>
  <pre><code>import pygame
  import os
  pygame.init()
  pygame.font.init()
  
  WIDTH, HEIGHT = (900, 500)
  WIN = pygame.display.set_mode((WIDTH, HEIGHT))
  pygame.display.set_caption('Bong Pong')
  
  
  
  FPS = 60
  WHITE = (255, 255, 255)
  BLACK = (0, 0, 0)
  RED = (255, 0, 0)
  BORDER = pygame.Rect(WIDTH// 2 -5, 0, 10, HEIGHT)
  VEL = 5
  PLAYER_HEIGHT = 50
  PLAYER_WIDTH = 15
  BALL_HEIGHT = 15
  BALL_WIDTH = 15
  
  SCORE_FONT = pygame.font.SysFont('timesnewroman', 40)
  WINNER_FONT = pygame.font.SysFont('timesnewroman', 40)
  
  def draw_window(player_1, player_2, game_ball, player_1_score, player_2_score):
      WIN.fill(WHITE)
      pygame.draw.rect(WIN, BLACK, BORDER)
      pygame.draw.rect(WIN, BLACK, player_1)
      pygame.draw.rect(WIN, BLACK, player_2)
      pygame.draw.rect(WIN, RED, game_ball)
      player_1_score_text = SCORE_FONT.render(&quot;Score: &quot; + str(player_1_score), 1, BLACK)
      player_2_score_text = SCORE_FONT.render(&quot;Score: &quot; + str(player_2_score), 1, BLACK)
      WIN.blit(player_1_score_text, (10, 10))
      WIN.blit(player_2_score_text, (480, 10))
      pygame.display.update()
  
  
  def player_1_movement(keys_pressed, player_1):
      if keys_pressed[pygame.K_w] and player_1.y - VEL &gt; 0:
          player_1.y -= VEL
      if keys_pressed [pygame.K_s] and player_1.y + PLAYER_HEIGHT + VEL &lt; 500:
          player_1.y += VEL
      
  def player_2_movement(keys_pressed, player_2):
      if keys_pressed[pygame.K_UP] and player_2.y - VEL &gt; 0:
          player_2.y -= VEL
      if keys_pressed [pygame.K_DOWN] and player_2.y + PLAYER_HEIGHT + VEL &lt; 500:
          player_2.y += VEL
  
         
  def draw_winner(text):
      winner_winner = WINNER_FONT.render(text ,1 , BLACK)
      WIN.blit(winner_winner, (WIDTH// 2 ,HEIGHT //2))
      pygame.display.update
      pygame.time.delay(3000)
      
  
  
  
  
      
          
     
          
      
      
  
  def main(): 
  
      player_1 = pygame.Rect(50, HEIGHT//2 - PLAYER_HEIGHT// 2, PLAYER_WIDTH, PLAYER_HEIGHT)
      player_2 = pygame.Rect(850, HEIGHT//2 - PLAYER_HEIGHT// 2, PLAYER_WIDTH, PLAYER_HEIGHT)
      game_ball = pygame.Rect(50 + PLAYER_WIDTH, HEIGHT//2 - BALL_HEIGHT// 2, BALL_WIDTH, BALL_HEIGHT)
      ball_vel_y = 2
      ball_vel_x = 2
      player_1_score = 0 
      player_2_score = 0 
  
  
      clock = pygame.time.Clock()
      run = True
      while run:
          clock.tick(FPS)
          for event in pygame.event.get():
              if event.type == pygame.QUIT:
                  run = False 
                  pygame.quit()
              
  
              
          keys_pressed = pygame.key.get_pressed()
          player_1_movement(keys_pressed, player_1)
          player_2_movement(keys_pressed, player_2)
          
          the_winner_text = &quot;&quot;
          if player_1_score == 1:
              the_winner_text = &quot;Player 1 Wins!&quot;
              return the_winner_text
          if player_2_score == 10:
              the_winner_text = &quot;Player 2 Wins!&quot;
              return the_winner_text
          if the_winner_text != &quot;&quot;:
              draw_winner(the_winner_text)
              break 
          # Swtich ball directions
          if game_ball.y - BALL_HEIGHT - VEL &lt;= 0 or game_ball.y + BALL_HEIGHT + VEL &gt;= 500:
              ball_vel_y *= -1
  
          # Start Movmeent
          game_ball.y -= ball_vel_y
  
          # Collisions
          if game_ball.colliderect(player_1) or game_ball.colliderect(player_2):
              ball_vel_x *= -1
          if game_ball.colliderect(player_1):
              ball_vel_x += 1
              ball_vel_y += 1
          if game_ball.colliderect(player_2):
              ball_vel_x -= 1
              ball_vel_y += 1
          # Start X movement
          game_ball.x += ball_vel_x
  
          # handles scoring and resets
          if game_ball.x &gt;= 900:
              player_1_score += 1
              pygame.time.delay(1000)
          if game_ball.x &gt; 900:
              game_ball.x = 50
              ball_vel_x = 2
              ball_vel_y = 2
          if game_ball.x &lt;= 0:
              player_2_score += 2
              pygame.time.delay(1000)
          if game_ball.x &lt; 0:
              game_ball.x = 850
              ball_vel_x = 2
              ball_vel_y = 2
  
          # Winning the game
  
          draw_window(player_1, player_2, game_ball, player_1_score, player_2_score)
          
     
  
  
      
  
  if __name__ == '__main__':
      main()
  
  </code></pre>
  <p>The Tutorial</p>
  <pre><code>import pygame
  import os
  pygame.font.init()
  pygame.mixer.init() 
  
  WIDTH, HEIGHT = 900,500
  WIN = pygame.display.set_mode((WIDTH, HEIGHT))
  pygame.display.set_caption(&quot;The First Game&quot;)
  
  HEALTH_FONT = pygame.font.SysFont('timesnewroman', 40)
  WINNER_FONT = pygame.font.SysFont('tiemsnewroman', 60)
  
  BLUE = (0, 0, 100)
  BLACK = (0, 0, 0)
  RED = (200, 0, 0)
  YELLOW = (0, 200, 200)
  BORDER = pygame.Rect(WIDTH//2 - 5, 0, 10, HEIGHT)
  VEL = 7
  MAX_BULLETS = 3
  BULLET_VEL = 10
  FPS = 60
  
  
  
  YELLOW_HIT = pygame.USEREVENT + 1
  RED_HIT = pygame.USEREVENT + 2 
  
  SPACESHIP_WIDTH, SPACESHIP_HEIGHT = 55,40
  
  YELLOW_SPACESHIP_IMAGE = pygame.image.load(os.path.join('Pygame Tutorial', 'Assets', 'spaceship_yellow.png'))
  YELLOW_SPACESHIP = pygame.transform.rotate(pygame.transform.scale(YELLOW_SPACESHIP_IMAGE, (SPACESHIP_WIDTH, SPACESHIP_HEIGHT)), 90)
  
  RED_SPACESHIP_IMAGE = pygame.image.load(os.path.join('Pygame Tutorial', 'Assets', 'spaceship_red.png'))
  RED_SPACESHIP = pygame.transform.rotate(pygame.transform.scale(RED_SPACESHIP_IMAGE, (SPACESHIP_WIDTH, SPACESHIP_HEIGHT)), 270)
  
  SPACE_BACKGROUND = pygame.transform.scale(pygame.image.load(os.path.join('Pygame Tutorial', 'Assets', 'space.png')), (900, 500))
  
  
  
  def draw_window(red, yellow, red_bullets, yellow_bullets, red_health, yellow_health):
      WIN.blit(SPACE_BACKGROUND, (0, 0))
      pygame.draw.rect(WIN, BLACK, BORDER)
      
      red_health_text = HEALTH_FONT.render(&quot;Health: &quot; + str(red_health), 1, BLUE)
      yellow_health_text = HEALTH_FONT.render(&quot;Health: &quot; + str(yellow_health), 1, BLUE)
  
      WIN.blit(red_health_text, (WIDTH - red_health_text.get_width() -10, 10))
      WIN.blit(yellow_health_text, (10, 10))
      WIN.blit(YELLOW_SPACESHIP, (yellow.x, yellow.y))
      WIN.blit(RED_SPACESHIP, (red.x, red.y))
  
  
  
      for bullet in red_bullets:
          pygame.draw.rect(WIN, RED, bullet )
  
      for bullet in yellow_bullets:
          pygame.draw.rect(WIN, YELLOW, bullet )
  
      pygame.display.update()
  
  
  
  def yellow_movement(keys_pressed, yellow):
      if keys_pressed[pygame.K_a] and yellow.x - VEL &gt; 0: #left
          yellow.x -= VEL
      if keys_pressed[pygame.K_d] and yellow.x + VEL + yellow.width &lt; BORDER.x + BORDER.width: #right
          yellow.x += VEL
      if keys_pressed[pygame.K_w] and yellow.y - VEL &gt; 0: #up
          yellow.y -= VEL
      if keys_pressed[pygame.K_s] and yellow.y + VEL + yellow.height &lt; HEIGHT - 15:
          yellow.y += VEL
  
  def red_movement(keys_pressed, red):
      if keys_pressed[pygame.K_LEFT] and red.x - VEL &gt; BORDER.x + BORDER.width: #left
              red.x -= VEL
      if keys_pressed[pygame.K_RIGHT] and red.x + VEL + red.width &lt; WIDTH: #right
              red.x += VEL
      if keys_pressed[pygame.K_UP] and red.y - VEL &gt; 0: #up
              red.y -= VEL
      if keys_pressed[pygame.K_DOWN] and red.y + VEL + red.height &lt; HEIGHT - 15: #down
              red.y += VEL
  
  def handle_bullets(yellow_bullets, red_bullets, yellow, red):
      for bullet in yellow_bullets:
          bullet.x += BULLET_VEL
          if red.colliderect(bullet):
              pygame.event.post(pygame.event.Event(RED_HIT))
              yellow_bullets.remove(bullet)
          if bullet.x &gt; 900:
              yellow_bullets.remove(bullet)
  
      for bullet in red_bullets:
          bullet.x -= BULLET_VEL
          if yellow.colliderect(bullet):
              pygame.event.post(pygame.event.Event(YELLOW_HIT))
              red_bullets.remove(bullet)
  
          if bullet.x &lt; 0:
              red_bullets.remove(bullet)
  
  def draw_winner(text):
      the_winner_text = WINNER_FONT.render(text, 1, BLACK)
      WIN.blit(the_winner_text, (WIDTH // 2 - the_winner_text.get_width()// 2, HEIGHT //2))
      pygame.display.update()
      pygame.time.delay(3000)
      
  
  def main():
      red = pygame.Rect(700, 300, SPACESHIP_WIDTH, SPACESHIP_HEIGHT)
      yellow = pygame.Rect(100, 300, SPACESHIP_WIDTH, SPACESHIP_HEIGHT)
  
      #game specific variables go inside of main function
      red_bullets = []
      yellow_bullets = []
      bullets = []
      red_health = 10
      yellow_health = 10
  
      clock = pygame.time.Clock()
      run = True
      while run:
          clock.tick(FPS)
          for event in pygame.event.get():
              if event.type == pygame.QUIT:
                  run = False
                  pygame.quit()
              
              if event.type == pygame.KEYDOWN:
                  if event.key == pygame.K_LCTRL and len(yellow_bullets) &lt; MAX_BULLETS:
                      bullet = pygame.Rect(yellow.x + yellow.width, yellow.y + yellow.height//2  +2, 10, 5) 
                      yellow_bullets.append(bullet)
                  if event.key == pygame.K_RCTRL and len(red_bullets) &lt; MAX_BULLETS:
                      bullet = pygame.Rect(red.x , red.y + red.height//2 +2, 10, 5) 
                      red_bullets.append(bullet)
  
              if event.type == RED_HIT:
                  red_health -= 1
  
              if event.type == YELLOW_HIT:
                  yellow_health -= 1
  
          winner_text = &quot;&quot;
  
          if red_health &lt;= 0:
                  winner_text = &quot;Yellow Wins!&quot;
              
          if yellow_health &lt;= 0:
                  winner_text = &quot;Red Wins!&quot;
  
          if winner_text != &quot;&quot;:
                  draw_winner(winner_text)
                  break
          
  
          keys_pressed = pygame.key.get_pressed()
          yellow_movement(keys_pressed, yellow)
          red_movement(keys_pressed, red)
  
          handle_bullets(yellow_bullets, red_bullets, yellow, red)
          draw_window(red, yellow, red_bullets, yellow_bullets, red_health, yellow_health)
  
          
      
      
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>
  <p>the part I'm looking at specifically is the draw_winner() function. It works perfectly fine in the tutorial but not my code and I've basically followed it exactly as far as I can tell.</p>