1

it is showing no error just bringing up a blank display instead of printng start at the bottom of display

import pygame
import time

pygame.init()

black = (0,0,0)
white = (255,255,255)

Display = pygame.display.set_mode((800,600))
pygame.display.set_caption('fitness')

font = pygame.font.SysFont(None,200)


def message_to_screen(msg,color):
    screen_text = font.render(msg,True,color)
    Display.blit(screen_text, [800/2, 600/2])

exercises =["pelvic shift","hanging","single leg hopping","puppy pose","side strech","low lunge                                                                               arcs",  "cobra strech","jogging,skipping","vertical bends","standing strechs","side bends","swimming","toe lifts","land swimming" ,"legs up alternate", "leg kicks" , "wake up stretchinggutes and hip bridges","forward spine stretch","cat camel back stetch","mermaid stretch","cycling","jump squats","cobra stretch","downward facing dog"  ,   "bird dog", "inversion table exercise", "surya namaskars" , "side planks"]             


def exerciseLoop():  
    for x in exercises:
        for number_of_exercise in range(1,29):   
            z = exercises.index(x)
            if number_of_exercise == (z+1):
                final={}
                final.update({number_of_exercise:x})
                message_to_screen("start",black)
                clock = pygame.time.Clock()
                FPS = 30
                clock.tick(FPS)
                Display.fill(white)
                pygame.display.update()
    

exerciseLoop()
Grismar
  • 27,561
  • 4
  • 31
  • 54
  • Maybe `number_of_exercise` is not equal to `z + 1`? – mkrieger1 Jan 06 '21 at 00:57
  • You have asked the same question twice: [stuck in an infinite loop,python,pygame](https://stackoverflow.com/questions/65587837/stuck-in-an-infinite-loop-python-pygame). You shouldn't do that. Improve the original question instead of asking the same question twice. – Rabbid76 Jan 06 '21 at 09:16

2 Answers2

0

The white is painted above the text. You need to paint it white first, then write the text:

import pygame
import time

pygame.init()

black = (0,0,0)
white = (255,255,255)

Display = pygame.display.set_mode((800,600))
pygame.display.set_caption('fitness')

font = pygame.font.SysFont(None,200)


def message_to_screen(msg,color):
    screen_text = font.render(msg,True,color)
    Display.blit(screen_text, [800/2, 600/2])

exercises =["pelvic shift","hanging","single leg hopping","puppy pose","side strech","low lunge                                                                               arcs",  "cobra strech","jogging,skipping","vertical bends","standing strechs","side bends","swimming","toe lifts","land swimming" ,"legs up alternate", "leg kicks" , "wake up stretchinggutes and hip bridges","forward spine stretch","cat camel back stetch","mermaid stretch","cycling","jump squats","cobra stretch","downward facing dog"  ,   "bird dog", "inversion table exercise", "surya namaskars" , "side planks"]             


def exerciseLoop():  
    for x in exercises:
        for number_of_exercise in range(1,29):   
            z = exercises.index(x)
            if number_of_exercise == (z+1):
                final={}
                final.update({number_of_exercise:x})
                Display.fill(white)
                message_to_screen("start",black)
                clock = pygame.time.Clock()
                FPS = 30
                clock.tick(FPS)
                pygame.display.update()
    

exerciseLoop()
wastl
  • 338
  • 2
  • 10
0

You have to handle the events in the application loop. See pygame.event.get() respectively pygame.event.pump():

For each frame of your game, you will need to make some sort of call to the event queue. This ensures your program can internally interact with the rest of the operating system.

def exerciseLoop():  
     
    clock = pygame.time.Clock()
    FPS = 30
    run = True
    while run:
        clock.tick(FPS)
        for event in pygame.event.get(): 
            if event.type == pygame.QUIT:
                run = False

        for x in exercises:
            for number_of_exercise in range(1,29):  
                
                z = exercises.index(x)
                if number_of_exercise == (z+1):
                    final={}
                    final.update({number_of_exercise:x})  
                
        Display.fill(white)
        message_to_screen("start",black)
                
        pygame.display.update()
    
exerciseLoop()

The typical PyGame application loop has to:

Rabbid76
  • 202,892
  • 27
  • 131
  • 174