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

1 Answer 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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.