Simple pygame program to fix
Question: I am new to Python and I have modified dodger (here's the link
<http://inventwithpython.com/dodger.py>) to add ''goodies'', sprites similar
to the baddies, but that give you score when you touch them; instead of
killing you as the baddies do. (I have made a change at the start with easygui
too, but it works fine).

I am really confused as this code works (I mean this code **starts**) but the
goodies don't appear, like if I didn't put them in at all. I have tried to
figure out by myself what the problem is but I haven't found it. The source
code is long but there are some comments to make it more readable. I think
that the multimedia files are right because it doesn't give me error messages.

Here you have the not working program:

    
    
    import pygame, random, sys
    from pygame.locals import *
    import easygui
    
    #Message to make the user decide the hardness of the game
    msg = 'Inserisci un numero da 1 a 20\n per la difficoltà: \n1 = Semplice\n 20 = Impossibile'
    title = 'Difficoltà'
    
    #Message to make the user decide the colour of the background of the game
    Difficoltà = easygui.enterbox(msg,title)
    msg   = "Quale colore preferisci fra questi come sfondo?"
    choices = ["Nero","Blu","Verde"]
    COLORESCELTODALLUTENTE = easygui.buttonbox(msg,choices=choices)
    
    #Unused Values as it runs in fullscreen mode
    WINDOWWIDTH = 800
    WINDOWHEIGHT = 600
    
    #The text is white
    TEXTCOLOR = (255, 255, 255)
    
    #Changes the colour of the background according to the choice of the user
    if COLORESCELTODALLUTENTE == 'Nero':
        BACKGROUNDCOLOR = (0, 0, 0)
    elif COLORESCELTODALLUTENTE == 'Blu':
        BACKGROUNDCOLOR = (36, 68, 212)
    elif COLORESCELTODALLUTENTE == 'Verde':
        BACKGROUNDCOLOR = (36, 237, 52)
    
    #Frames per second the game will run at
    FPS = 40
    
    #Description of the baddies
    baddie_type_1MINSIZE = 20
    baddie_type_1MAXSIZE = 40
    baddie_type_1MINSPEED = 4
    baddie_type_1MAXSPEED = 5
    ADDNEWbaddie_type_1RATE = 21 - int(Difficoltà)
    
    #Description of the goddies
    goddie_type_1MINSIZE = 20
    goddie_type_1MAXSIZE = 40
    goddie_type_1MINSPEED = 4
    goddie_type_1MAXSPEED = 5
    ADDNEWgoddie_type_1RATE = 10
    
    #How fast you move with the arrows
    PLAYERMOVERATE = 5
    
    def terminate():
        pygame.quit()
        sys.exit()
    
    def waitForPlayerToPressKey():
        while True:
            for event in pygame.event.get():
                if event.type == QUIT:
                    terminate()
                if event.type == KEYDOWN:
                    if event.key == K_ESCAPE: # pressing escape quits
                        terminate()
                    return
    
    def playerHasHitbaddie_type_1(playerRect, baddies_type_1):
        for b in baddies_type_1:
            if playerRect.colliderect(b['rect_b']):
                return True
        return False
    
    def playerHasHitgoddie_type_1(playerRect, goddies_type_1):
        for g in goddies_type_1:
            if playerRect.colliderect(g['rect_g']):
                return True
        return False
    
    def drawText(text, font, surface, x, y):
        textobj = font.render(text, 1, TEXTCOLOR)
        textrect = textobj.get_rect()
        textrect.topleft = (x, y)
        surface.blit(textobj, textrect)
    
    # set up pygame, the window, and the mouse cursor
    pygame.init()
    mainClock = pygame.time.Clock()
    #This down here is windowed mode
    #windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))
    #This down here is fullscreen mode
    windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), pygame.FULLSCREEN)
    pygame.display.set_caption('Dodger')
    pygame.mouse.set_visible(False)
    
    # set up fonts
    font = pygame.font.SysFont(None, 48)
    
    # set up sounds
    gameOverSound = pygame.mixer.Sound('Gameover.wav')
    pygame.mixer.music.load('Background.mp3')
    
    # set up images
    playerImage = pygame.image.load('Player.png')
    playerRect = playerImage.get_rect()
    baddie_type_1Image = pygame.image.load('Baddie_type_1.png')
    goddie_type_1Image = pygame.image.load('Goddie_type_1.png')
    
    # show the "Start" screen
    drawText('Dodger', font, windowSurface, (WINDOWWIDTH / 3), (WINDOWHEIGHT / 3))
    drawText('Press a key to start.', font, windowSurface, (WINDOWWIDTH / 3) - 30, (WINDOWHEIGHT / 3) + 50)
    pygame.display.update()
    waitForPlayerToPressKey()
    
    
    topScore = 0
    while True:
        # set up the start of the game
        baddies_type_1 = []
        goddies_type_1 = []
        score = 0
        playerRect.topleft = (WINDOWWIDTH / 2, WINDOWHEIGHT - 50)
        moveLeft = moveRight = moveUp = moveDown = False
        reverseCheat = slowCheat = False
        baddie_type_1AddCounter = 0
        goddie_type_1AddCounter = 0
        pygame.mixer.music.play(-1, 0.0)
    
        while True: # the game loop runs while the game part is playing
            score += 1 # increase score
    
            for event in pygame.event.get():
                if event.type == QUIT:
                    terminate()
    
                if event.type == KEYDOWN:
                    if event.key == ord('z'):
                        reverseCheat = True
                    if event.key == ord('x'):
                        slowCheat = True
                    if event.key == K_LEFT or event.key == ord('a'):
                        moveRight = False
                        moveLeft = True
                    if event.key == K_RIGHT or event.key == ord('d'):
                        moveLeft = False
                        moveRight = True
                    if event.key == K_UP or event.key == ord('w'):
                        moveDown = False
                        moveUp = True
                    if event.key == K_DOWN or event.key == ord('s'):
                        moveUp = False
                        moveDown = True
    
                if event.type == KEYUP:
                    if event.key == ord('z'):
                        reverseCheat = False
                        score = 0
                    if event.key == ord('x'):
                        slowCheat = False
                        score = 0
                    if event.key == K_ESCAPE:
                            terminate()
    
                    if event.key == K_LEFT or event.key == ord('a'):
                        moveLeft = False
                    if event.key == K_RIGHT or event.key == ord('d'):
                        moveRight = False
                    if event.key == K_UP or event.key == ord('w'):
                        moveUp = False
                    if event.key == K_DOWN or event.key == ord('s'):
                        moveDown = False
    
                if event.type == MOUSEMOTION:
                    # If the mouse moves, move the player where the cursor is.
                    playerRect.move_ip(event.pos[0] - playerRect.centerx, event.pos[1] - playerRect.centery)
    
            # ize is for size
            # Add new baddies_type_1 at the top of the screen, if needed.
            if not reverseCheat and not slowCheat:
                baddie_type_1AddCounter += 1
            if baddie_type_1AddCounter == ADDNEWbaddie_type_1RATE:
                baddie_type_1AddCounter = 0
                baddies_type_1ize = random.randint(baddie_type_1MINSIZE, baddie_type_1MAXSIZE)
                newbaddie_type_1 = {'rect_b': pygame.Rect(random.randint(0, WINDOWWIDTH-baddies_type_1ize), 0 - baddies_type_1ize, baddies_type_1ize, baddies_type_1ize),
                            'speed_b': random.randint(baddie_type_1MINSPEED, baddie_type_1MAXSPEED),
                            'surface_b':pygame.transform.scale(baddie_type_1Image, (baddies_type_1ize, baddies_type_1ize)),
                            }
    
                baddies_type_1.append(newbaddie_type_1)
    
            # ize is for size
            # Add new goddies_type_1 at the top of the screen, if needed.
            if not reverseCheat and not slowCheat:
                goddie_type_1AddCounter += 1
            if goddie_type_1AddCounter == ADDNEWgoddie_type_1RATE:
                goddie_type_1AddCounter = 0
                goddies_type_1ize = random.randint(goddie_type_1MINSIZE, goddie_type_1MAXSIZE)
                newgoddie_type_1 = {'rect_g': pygame.Rect(random.randint(0, WINDOWWIDTH-goddies_type_1ize), 0 - goddies_type_1ize, goddies_type_1ize, goddies_type_1ize),
                            'speed_g': random.randint(goddie_type_1MINSPEED, goddie_type_1MAXSPEED),
                            'surface_g':pygame.transform.scale(goddie_type_1Image, (goddies_type_1ize, goddies_type_1ize)),
                            }
    
            # Move the player around.
            if moveLeft and playerRect.left > 0:
                playerRect.move_ip(-1 * PLAYERMOVERATE, 0)
            if moveRight and playerRect.right < WINDOWWIDTH:
                playerRect.move_ip(PLAYERMOVERATE, 0)
            if moveUp and playerRect.top > 0:
                playerRect.move_ip(0, -1 * PLAYERMOVERATE)
            if moveDown and playerRect.bottom < WINDOWHEIGHT:
                playerRect.move_ip(0, PLAYERMOVERATE)
    
            # Move the mouse cursor to match the player.
            pygame.mouse.set_pos(playerRect.centerx, playerRect.centery)
    
            # Move the baddies_type_1 down.
            for b in baddies_type_1:
                if not reverseCheat and not slowCheat:
                    b['rect_b'].move_ip(0, b['speed_b'])
                elif reverseCheat:
                    b['rect_b'].move_ip(0, -5)
                elif slowCheat:
                    b['rect_b'].move_ip(0, 1)
    
            # Move the goddies_type_1 down.
            for g in goddies_type_1:
                if not reverseCheat and not slowCheat:
                    g['rect_g'].move_ip(0, g['speed_g'])
                elif reverseCheat:
                    g['rect_g'].move_ip(0, -5)
                elif slowCheat:
                    g['rect_g'].move_ip(0, 1)
    
    
             # Delete baddies_type_1 that have fallen past the bottom.
            for b in baddies_type_1[:]:
                if b['rect_b'].top > WINDOWHEIGHT:
                    baddies_type_1.remove(b)
    
            # Delete goddies_type_1 that have fallen past the bottom.
            for g in goddies_type_1[:]:
                if g['rect_g'].top > WINDOWHEIGHT:
                    goddies_type_1.remove(g)
    
            # Draw the game world on the window.
            windowSurface.fill(BACKGROUNDCOLOR)
    
            # Draw the score and top score.
            drawText('Score: %s' % (score), font, windowSurface, 10, 0)
            drawText('Top Score: %s' % (topScore), font, windowSurface, 10, 40)
    
            # Draw the player's rectangle
            windowSurface.blit(playerImage, playerRect)
    
            # Draw each baddie_type_1
            for b in baddies_type_1:
                windowSurface.blit(b['surface_b'], b['rect_b'])
    
            # Draw each goddie_type_1
            for g in goddies_type_1:
                windowSurface.blit(g['surface_g'], g['rect_g'])
    
    
            pygame.display.update()
    
            # Check if any of the baddies_type_1 have hit the player.
            if playerHasHitbaddie_type_1(playerRect, baddies_type_1):
                if score > topScore:
                    topScore = score # set new top score
                break
    
            # Check if any of the goddies_type_1 have hit the player.
            if playerHasHitgoddie_type_1(playerRect, goddies_type_1):
                score = score + 200
    
            #Frapes of the game
            mainClock.tick(FPS)
    
        # Stop the game and show the "Game Over" screen.
        pygame.mixer.music.stop()
        gameOverSound.play()
    
        drawText('GAME OVER', font, windowSurface, (WINDOWWIDTH / 3), (WINDOWHEIGHT / 3))
        drawText('Press a key to play again.', font, windowSurface, (WINDOWWIDTH / 3) - 80, (WINDOWHEIGHT / 3) + 50)
        pygame.display.update()
        waitForPlayerToPressKey()
    
        gameOverSound.stop()
    


Answer: After your `# Add new baddies_type_1 at the top of the screen, if needed.`
code, it looks like you actually add the baddie with this line:

`baddies_type_1.append(newbaddie_type_1)`

You don't appear to be doing that with your goodies code. Try adding:

`goddies_type_1.append(newgoddie_type_1)`

after your `# Add new goddies_type_1 at the top of the screen, if needed.` if
statements.

Also, you spelled `goodies` as `goddies` throughout your code.

