Text not displaying in Pygame












0















Problem - I'm trying to make a start menu for a simon says game and trying to first display some text however nothing displays other than the game screen turning white (which should happen). I've looked at a similar questions and they don't seem to help.



The program should just display 'Simon says' in black writing on the screen



code:



import pygame,random,pickle,time

WHITE = (255,255,255)
BLACK = (0,0,0)
RED = (255,0,0)
GREEN = (0,255,0)
BLUE = (0,0,255)
YELLOW = (255,255,0)
PURPLE = (128,0,128)
CYAN = (0,255,255)
ORANGE = (255,165,0)
PINK = (255,192,203)

pygame.init()
logo = pygame.image.load("logo.png")
pygame.display.set_icon(logo)
pygame.display.set_caption("Simon Says")

screen = pygame.display.set_mode((1280,720))

def textObjects(text,font):
textSurface = font.render(text,True,BLACK)
return textSurface, textSurface.get_rect()

def displayText(text):
fontInfo = pygame.font.Font(None,100)
textSurf, textSize = textObjects(text,fontInfo)
textSize.center = ((1280/2),(720/2))
screen.blit(textSurf,textSize)
pygame.display.update()

def startMenu():
displayText('Simon Says')
def main():
startMenu()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill(WHITE)
pygame.display.update()
pygame.display.flip()

main()


Also tried using pygame.display.flip() and that didn't work eithter










share|improve this question





























    0















    Problem - I'm trying to make a start menu for a simon says game and trying to first display some text however nothing displays other than the game screen turning white (which should happen). I've looked at a similar questions and they don't seem to help.



    The program should just display 'Simon says' in black writing on the screen



    code:



    import pygame,random,pickle,time

    WHITE = (255,255,255)
    BLACK = (0,0,0)
    RED = (255,0,0)
    GREEN = (0,255,0)
    BLUE = (0,0,255)
    YELLOW = (255,255,0)
    PURPLE = (128,0,128)
    CYAN = (0,255,255)
    ORANGE = (255,165,0)
    PINK = (255,192,203)

    pygame.init()
    logo = pygame.image.load("logo.png")
    pygame.display.set_icon(logo)
    pygame.display.set_caption("Simon Says")

    screen = pygame.display.set_mode((1280,720))

    def textObjects(text,font):
    textSurface = font.render(text,True,BLACK)
    return textSurface, textSurface.get_rect()

    def displayText(text):
    fontInfo = pygame.font.Font(None,100)
    textSurf, textSize = textObjects(text,fontInfo)
    textSize.center = ((1280/2),(720/2))
    screen.blit(textSurf,textSize)
    pygame.display.update()

    def startMenu():
    displayText('Simon Says')
    def main():
    startMenu()
    running = True
    while running:
    for event in pygame.event.get():
    if event.type == pygame.QUIT:
    running = False
    screen.fill(WHITE)
    pygame.display.update()
    pygame.display.flip()

    main()


    Also tried using pygame.display.flip() and that didn't work eithter










    share|improve this question



























      0












      0








      0








      Problem - I'm trying to make a start menu for a simon says game and trying to first display some text however nothing displays other than the game screen turning white (which should happen). I've looked at a similar questions and they don't seem to help.



      The program should just display 'Simon says' in black writing on the screen



      code:



      import pygame,random,pickle,time

      WHITE = (255,255,255)
      BLACK = (0,0,0)
      RED = (255,0,0)
      GREEN = (0,255,0)
      BLUE = (0,0,255)
      YELLOW = (255,255,0)
      PURPLE = (128,0,128)
      CYAN = (0,255,255)
      ORANGE = (255,165,0)
      PINK = (255,192,203)

      pygame.init()
      logo = pygame.image.load("logo.png")
      pygame.display.set_icon(logo)
      pygame.display.set_caption("Simon Says")

      screen = pygame.display.set_mode((1280,720))

      def textObjects(text,font):
      textSurface = font.render(text,True,BLACK)
      return textSurface, textSurface.get_rect()

      def displayText(text):
      fontInfo = pygame.font.Font(None,100)
      textSurf, textSize = textObjects(text,fontInfo)
      textSize.center = ((1280/2),(720/2))
      screen.blit(textSurf,textSize)
      pygame.display.update()

      def startMenu():
      displayText('Simon Says')
      def main():
      startMenu()
      running = True
      while running:
      for event in pygame.event.get():
      if event.type == pygame.QUIT:
      running = False
      screen.fill(WHITE)
      pygame.display.update()
      pygame.display.flip()

      main()


      Also tried using pygame.display.flip() and that didn't work eithter










      share|improve this question
















      Problem - I'm trying to make a start menu for a simon says game and trying to first display some text however nothing displays other than the game screen turning white (which should happen). I've looked at a similar questions and they don't seem to help.



      The program should just display 'Simon says' in black writing on the screen



      code:



      import pygame,random,pickle,time

      WHITE = (255,255,255)
      BLACK = (0,0,0)
      RED = (255,0,0)
      GREEN = (0,255,0)
      BLUE = (0,0,255)
      YELLOW = (255,255,0)
      PURPLE = (128,0,128)
      CYAN = (0,255,255)
      ORANGE = (255,165,0)
      PINK = (255,192,203)

      pygame.init()
      logo = pygame.image.load("logo.png")
      pygame.display.set_icon(logo)
      pygame.display.set_caption("Simon Says")

      screen = pygame.display.set_mode((1280,720))

      def textObjects(text,font):
      textSurface = font.render(text,True,BLACK)
      return textSurface, textSurface.get_rect()

      def displayText(text):
      fontInfo = pygame.font.Font(None,100)
      textSurf, textSize = textObjects(text,fontInfo)
      textSize.center = ((1280/2),(720/2))
      screen.blit(textSurf,textSize)
      pygame.display.update()

      def startMenu():
      displayText('Simon Says')
      def main():
      startMenu()
      running = True
      while running:
      for event in pygame.event.get():
      if event.type == pygame.QUIT:
      running = False
      screen.fill(WHITE)
      pygame.display.update()
      pygame.display.flip()

      main()


      Also tried using pygame.display.flip() and that didn't work eithter







      python text pygame game-development






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 21:13









      eyllanesc

      75.4k103156




      75.4k103156










      asked Nov 20 '18 at 19:28









      Tavian TTavian T

      31




      31
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Actually everything works just fine, but you have one simple mistake.
          Notice at the first line that you are calling the



          startMenu()


          function, which basically draws the text 'Simon says' onto the screen.
          BUT also, right after that you are filling the screen white.
          So it draws the surface of the text and renders it onto screen, and right after it turns the screen white (basically it draws white color over your text surface).
          Thus if you want it to appear, just place that function AFTER this line:



          screen.fill(WHITE)





          share|improve this answer
























          • Thank you, works now!

            – Tavian T
            Nov 21 '18 at 11:23











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400207%2ftext-not-displaying-in-pygame%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Actually everything works just fine, but you have one simple mistake.
          Notice at the first line that you are calling the



          startMenu()


          function, which basically draws the text 'Simon says' onto the screen.
          BUT also, right after that you are filling the screen white.
          So it draws the surface of the text and renders it onto screen, and right after it turns the screen white (basically it draws white color over your text surface).
          Thus if you want it to appear, just place that function AFTER this line:



          screen.fill(WHITE)





          share|improve this answer
























          • Thank you, works now!

            – Tavian T
            Nov 21 '18 at 11:23
















          1














          Actually everything works just fine, but you have one simple mistake.
          Notice at the first line that you are calling the



          startMenu()


          function, which basically draws the text 'Simon says' onto the screen.
          BUT also, right after that you are filling the screen white.
          So it draws the surface of the text and renders it onto screen, and right after it turns the screen white (basically it draws white color over your text surface).
          Thus if you want it to appear, just place that function AFTER this line:



          screen.fill(WHITE)





          share|improve this answer
























          • Thank you, works now!

            – Tavian T
            Nov 21 '18 at 11:23














          1












          1








          1







          Actually everything works just fine, but you have one simple mistake.
          Notice at the first line that you are calling the



          startMenu()


          function, which basically draws the text 'Simon says' onto the screen.
          BUT also, right after that you are filling the screen white.
          So it draws the surface of the text and renders it onto screen, and right after it turns the screen white (basically it draws white color over your text surface).
          Thus if you want it to appear, just place that function AFTER this line:



          screen.fill(WHITE)





          share|improve this answer













          Actually everything works just fine, but you have one simple mistake.
          Notice at the first line that you are calling the



          startMenu()


          function, which basically draws the text 'Simon says' onto the screen.
          BUT also, right after that you are filling the screen white.
          So it draws the surface of the text and renders it onto screen, and right after it turns the screen white (basically it draws white color over your text surface).
          Thus if you want it to appear, just place that function AFTER this line:



          screen.fill(WHITE)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 19:57









          Emanuel LEmanuel L

          658




          658













          • Thank you, works now!

            – Tavian T
            Nov 21 '18 at 11:23



















          • Thank you, works now!

            – Tavian T
            Nov 21 '18 at 11:23

















          Thank you, works now!

          – Tavian T
          Nov 21 '18 at 11:23





          Thank you, works now!

          – Tavian T
          Nov 21 '18 at 11:23


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400207%2ftext-not-displaying-in-pygame%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy