title: How do I make my start screen for my python game to load?
body: <p>SO I am trying to make a start screen for my game but it wont work, as soon as I start my game, The screen turns dark for around 3 seconds than the game just starts playing, I get no errors and nothing the game just starts playing. I am not really sure what to do and how to fix it,</p>
  <p><a href="https://gyazo.com/7ea9a5d3dba4cc8893421d1812479514" rel="nofollow noreferrer">https://gyazo.com/7ea9a5d3dba4cc8893421d1812479514</a> this is a video to show whats happening.</p>
  <pre><code>def button(msg,x,y,w,h,ic,ac,action=None):
      mouse = pygame.mouse.get_pos()
      click = pygame.mouse.get_pressed()
      print(click)
      if x+w &gt; mouse[0] &gt; x and y+h &gt; mouse[1] &gt; y:
          pygame.draw.rect(gameDisplay, ac,(x,y,w,h))
  
          if click[0] == 1 and action != None:
              action()         
      else:
          pygame.draw.rect(gameDisplay, ic,(x,y,w,h))
  
      smallText = pygame.font.SysFont(&quot;comicsansms&quot;,20)
      textSurf, textRect = text_objects(msg, smallText)
      textRect.center = ( (x+(w/2)), (y+(h/2)) )
      gameDisplay.blit(textSurf, textRect)
  
          
  def game_intro():
  
      intro = True
  
      while intro:
          for event in pygame.event.get():
              #print(event)
              if event.type == pygame.QUIT:
                  pygame.quit()
                  quit()
                  
          window.fill((255,255,255))
          largeText = pygame.font.SysFont(&quot;comicsansms&quot;,115)
          TextSurf, TextRect = text_objects(&quot;A bit Racey&quot;, largeText)
          TextRect.center = ((600/2),(600/2))
          window.blit(TextSurf, TextRect)
  
          button(&quot;GO!&quot;,150,450,100,50,green,bright_green,game_loop)
          button(&quot;Quit&quot;,550,450,100,50,red,bright_red,quitgame)
  
          pygame.display.update()
          clock.tick(15)
  </code></pre>
  <pre><code>My Full code:
  
  
  
  
  import pygame
  pygame.init()
  
  #this is screem height
  window = pygame.display.set_mode((500,500))
  
  #know we put screem name
  pygame.display.set_caption(&quot;Noobs first Game&quot;)
  
  
  
  
  
  
  def button(msg,x,y,w,h,ic,ac,action=None):
      mouse = pygame.mouse.get_pos()
      click = pygame.mouse.get_pressed()
      print(click)
      if x+w &gt; mouse[0] &gt; x and y+h &gt; mouse[1] &gt; y:
          pygame.draw.rect(gameDisplay, ac,(x,y,w,h))
  
          if click[0] == 1 and action != None:
              action()         
      else:
          pygame.draw.rect(gameDisplay, ic,(x,y,w,h))
  
      smallText = pygame.font.SysFont(&quot;comicsansms&quot;,20)
      textSurf, textRect = text_objects(msg, smallText)
      textRect.center = ( (x+(w/2)), (y+(h/2)) )
      gameDisplay.blit(textSurf, textRect)
  
          
  def game_intro():
  
      intro = True
  
      while intro:
          for event in pygame.event.get():
              #print(event)
              if event.type == pygame.QUIT:
                  pygame.quit()
                  quit()
                  
          window.fill(white)
          largeText = pygame.font.SysFont(&quot;comicsansms&quot;,115)
          TextSurf, TextRect = text_objects(&quot;A bit Racey&quot;, largeText)
          TextRect.center = ((600/2),(600/2))
          window.blit(TextSurf, TextRect)
  
          button(&quot;GO!&quot;,150,450,100,50,green,bright_green,game_loop)
          button(&quot;Quit&quot;,550,450,100,50,red,bright_red,quitgame)
  
          pygame.display.update()
          clock.tick(15)
          
  
  
  
  
  
  
  
  
  
  bg = pygame.image.load(&quot;New.png&quot;)
  
  gg = pygame.image.load(&quot;lol.png&quot;)
  
  Rule2 = pygame.image.load(&quot;one1.png&quot;)
  
  Rule1 = pygame.image.load(&quot;two2.png&quot;)
  
  Rule3 = pygame.image.load(&quot;three3.png&quot;)
  
  Rule4 = pygame.image.load(&quot;four4.png&quot;)
  
  Rule5 = pygame.image.load(&quot;five5.png&quot;)
  
  Rule6 = pygame.image.load(&quot;six6.png&quot;)
  
  #player class
  class player:
      def __init__(self,x,y,width,height,color):
          self.x = x
          self.y = y
          self.width = width
          self.height = height
          self.color = color
          self.speed = 5
          self.isJump = False
          self.JumpCount = 10
          self.fall = 0
          self.rect = pygame.Rect(x,y,height,width)
      def draw(self):
          self.rect.topleft = (self.x,self.y)
          pygame.draw.rect(window,self.color,self.rect)
  
  class platform:
      def __init__(self,x,y,width,height,color):
          self.x = x
          self.y = y
          self.height = height
          self.width = width
          self.color = color
          self.rect = pygame.Rect(x,y,height,width)
          self.ss1 = pygame.image.load(&quot;Rock.png&quot;)
          self.ss1 = pygame.transform.scale(self.ss1,(self.ss1.get_width()//2,self.ss1.get_height()//2))
          self.hitbox = (self.x + 20 , self.y,58,60)
      def draw(self):
          self.rect.topleft=(self.x,self.y)
  
          player_rect = self.ss1.get_rect(center = self.rect.center)
          player_rect.centerx += 70
          player_rect.centery += 88
          window.blit(self.ss1,player_rect)
          self.hitbox = (self.x + 20 , self.y,58,60)
  
  class item:
      def __init__(self,x,y,width,height,color):
          self.x = x
          self.y = y
          self.height = height
          self.width = width
          self.color = color
          self.rect = pygame.Rect(x,y,height,width)
          self.ss1 = pygame.image.load(&quot;H6.png&quot;)
          self.ss1 = pygame.transform.scale(self.ss1,(self.ss1.get_width()//2,self.ss1.get_height()//2))
      def draw(self):
          self.rect.topleft = (self.x,self.y)
          window.blit(self.ss1,self.rect)
          
          
  class wall:
      def __init__(self,x,y,width,height,color):
          self.x = x
          self.y = y
          self.height = height
          self.width = width
          self.color = color
          self.rect = pygame.Rect(x,y,height,width)
      def draw(self):
          self.rect.topleft = (self.x,self.y)
          pygame.draw.rect(window,self.color,self.rect)
  
  
  #draw player
  white = (255,255,255)
  player1 = player(255,400,30,30,white)
  
  darkred = (200,0,0)
  
  darkgreen = (0,200,0)
  
  item1 = item(200,-500,50,50,white)
  item2 = item(250,250,50,50,white)
  item3 = item(330,-1030,50,50,white)
  item4 = item(400,-2290,50,50,white)
  item5 = item(300,-1600,50,50,white)
  item6 = item(200,130,50,50,white)
  item7 = item(230,-1830,50,50,white)
  item8 = item(300,0,50,50,white)
  item9 = item(330,-1440,50,50,white)
  item10 = item(20,-160,50,50,white)
  
  items = [item1,item2,item3,item4,item5,item6,item7,item8,item9,item10]
  
  green = (0,255,0)
  orange = (255,0,0)
  platform1 = platform(100,300,10,60,orange)
  platform2 = platform(5,200,10,60,orange)
  platform3 = platform(5,400,10,60,orange)
  platform4 = platform(100,100,10,60,orange)
  platform5 = platform(5,-50,10,60,orange)
  platform6 = platform(100,-200,10,60,orange)
  platform7 = platform(5,400,60,600,orange)
  platform8 = platform(300,-2430,10,60,orange)
  platform9 = platform (350,-340,10,60,orange)
  platform10 = platform (100,-470,10,60,orange)
  
  platform13 = platform(330,-600,10,60,orange)
  platform14 = platform(100,-790,10,60,orange)
  platform15 = platform(330,-990,10,60,orange)
  platform16 = platform(70,-1130,10,60,orange)
  platform17 = platform(200,-1340,10,60,orange)
  platform18 = platform(400,-1500,10,60,orange)
  platform19 = platform(300,-1700,10,60,orange)
  platform20 = platform(100,-1950,10,60,orange)
  platform21 = platform (350,-2140,10,60,orange)
  platform22 = platform (100,-2270,10,60,orange)
  platform23 = platform(0,-2500,60,500,green)
  
  
  #walls
  platform11 = wall (485,-9600,10000,10,orange)
  platform12 = wall (0,-9600,10000,10,orange)
  wall1 = wall (0,400,60,500,orange)
  wall2 = wall (0,-2500,60,500,green)
  wall3 = wall (485,-9600,10000,10,orange)
  wall4 = wall (0,-9600,10000,10,orange)
  
  
  walls = [wall1,wall2]
  
  
  
  platforms = (platform1,platform2,platform3,platform4,platform5,platform6,platform7,platform8,platform9,platform10,platform13,platform14,platform15,platform16,platform17,platform18,platform19,platform20,platform21,platform22,platform23)
  
  #window
  def redrawwindow():
      window.fill((0,0,0))
  
      window.blit(bg,(0,0))
  
      #draw plyer
      player1.draw()
      platform11.draw()
      platform12.draw()
      wall3.draw()
      wall4.draw()
      for platform in platforms:
          platform.draw()
      for item in items:
          item.draw()
      for wall in walls:
          wall.draw()
  
  # the score draw it on the screen
      window.blit(text,textRect)
      
  
  fps = (60)
  clock = pygame.time.Clock()
  
  
  font  = pygame.font.Font(&quot;freesansbold.ttf&quot;,30)
  score = 0
  text = font.render(&quot;Coins = &quot;+str(score),True,(255,255,255))
  textRect = text.get_rect()
  textRect.center = ((100,40))
  
  def button(msg,x,y,w,h,ic,ac,action=None):
      mouse = pygame.mouse.get_pos()
      click = pygame.mouse.get_pressed()
      print(click)
      if x+w &gt; mouse[0] &gt; x and y+h &gt; mouse[1] &gt; y:
          pygame.draw.rect(gameDisplay, ac,(x,y,w,h))
  
          if click[0] == 1 and action != None:
              action()         
      else:
          pygame.draw.rect(gameDisplay, ic,(x,y,w,h))
  
      smallText = pygame.font.SysFont(&quot;comicsansms&quot;,20)
      textSurf, textRect = text_objects(msg, smallText)
      textRect.center = ( (x+(w/2)), (y+(h/2)) )
      gameDisplay.blit(textSurf, textRect)
  
          
  def game_intro():
  
      intro = True
  
      while intro:
          for event in pygame.event.get():
              #print(event)
              if event.type == pygame.QUIT:
                  pygame.quit()
                  quit()
                  
          window.fill((255,255,255))
          largeText = pygame.font.SysFont(&quot;comicsansms&quot;,115)
          TextSurf, TextRect = text_objects(&quot;A bit Racey&quot;, largeText)
          TextRect.center = ((600/2),(600/2))
          window.blit(TextSurf, TextRect)
  
          button(&quot;GO!&quot;,150,450,100,50,green,bright_green,game_loop)
          button(&quot;Quit&quot;,550,450,100,50,red,bright_red,quitgame)
  
          pygame.display.update()
          clock.tick(15)
          
          
  
  run = True
  while run:
      clock.tick(fps)
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              run = False
          
  
  
  
      # coin collisions
      for item in items:
          for one in range(len(items)-1,-1,-1):
              if player1.rect.colliderect(items[one].rect):
                  del items[one]
                  score += 1
                  text = font.render(&quot;Coins = &quot;+str(score),True,(255,255,255))
                  textRect.center = ((100,40))
          
      #walls
      if player1.rect.colliderect(platform11) and player1.rect.colliderect(platform12):
          player1.x = 40
  
          # this makes you scroll up
      if player1.y &lt; 250:
          player1.y += 1
          #platforms
          for platform in platforms:
              platform.y += player1.speed
  
          for item in items:
              item.y += player1.speed
  
          for wall in walls:
              wall.y += player1.speed
              #walls
          platform11.y += player1.speed
          platform12.y += player1.speed
  
          # this makes you scroll down
      if player1.y &gt; 450:
          player1.y -= player1.fall
          for platform in platforms:
              platform.y -= player1.fall
          platform11.y -= player1.fall
          platform12.y -= player1.fall
  
  
          for item in items:
              item.y -= player1.fall
  
          for wall in walls:
              wall.y -= player1.fall
      #keys
      keys = pygame.key.get_pressed()
      
  
  
      keys = pygame.key.get_pressed()
  
      if keys[pygame.K_a]and player1.x &gt; player1.speed:
          player1.x -= player1.speed
  
      if keys[pygame.K_d]and player1.x &lt;500 - player1.height - player1.speed:
          player1.x += player1.speed
  
      if keys[pygame.K_w]and player1.y &gt; player1.speed:
          player1.y -= player1.speed
  
      if keys[pygame.K_s]and player1.y &lt;500 - player1.width - player1.speed:
          player1.y += player1.speed
  
      if not player1.isJump:
          player1.y += player1.fall
          player1.fall += 1
          player1.isJump = False
  
          collide = False
          # this part lets you jump on platform
          for platform in platforms:
              if player1.rect.colliderect(platform.rect):
                  collide = True
                  player1.isJump = False
                  player1.y = platform.rect.top - player1.height + 1
                  if player1.rect.right &gt; platform.rect.left and player1.rect.left &lt; platform.rect.left - player1.width:
                      player1.x = platform.rect.left - player1.width
                  if player1.rect.left &lt; platform.rect.right and player1.rect.right &gt; platform.rect.right + player1.width:
                      player1.x = platform.rect.right
      
              
  
              if player1.rect.bottom &gt;= 500:
                  collide = True
                  player1.isJump = False
                  player1.JumpCount = 10
                  player1.y = 500 - player1.height
  
          if collide:
              if keys[pygame.K_SPACE]:
                  player1.isJump = True
              player1.fall = 0
  
  
      else:
          if player1.JumpCount &gt;= 0:
              player1.y -= (player1.JumpCount*abs(player1.JumpCount))*0.3
              player1.JumpCount -= 1
          else:
              player1.JumpCount = 10
              player1.isJump = False
  
          
  
      redrawwindow()
      if player1.rect.colliderect(platform6):
          window.blit(Rule3,(-150,-80))
          
      if player1.rect.colliderect(platform2.rect):
          window.blit(Rule1,(-30,0))
          
      if player1.rect.colliderect(platform23.rect):
          window.blit(gg,(100,100))
          
      if player1.rect.colliderect(platform7.rect):
          window.blit(Rule2,(-70,0))
  
          
      if player1.rect.colliderect(platform1.rect):
          window.blit(Rule4,(-40,100))
  
      if player1.rect.colliderect(platform14.rect):
          window.blit(Rule5,(-50,0))
  
      if player1.rect.colliderect(platform17.rect):
          window.blit(Rule6,(-50,0))
  
      pygame.display.update()
  pygame.quit()
  game_intro()
  
  
  
  
  
              
  
  
  </code></pre>