my code shows no errors but right now my flappy bird cosde should be printing the word pipe every 1.2 seconds but it does not i do not know how to fix it and have checked every word in my code and i haev even re written it onec can anyone please help me code:

import pygame, sys

def draw_floor():
    screen.blit(floor_surface, (floor_animation, 400))
    screen.blit(floor_surface, (floor_animation + 275,400))

pygame.init()

screen = pygame.display.set_mode((275,512))
clock = pygame.time.Clock()

gravity = 0.25
bird_movement = 0

bg_surface = pygame.image.load('C:/Users/cuerv/Downloads/flappy-bird-assets-master/flappy-bird-assets-master/sprites/background-day.png').convert()

floor_surface = pygame.image.load('C:/Users/cuerv/Downloads/flappy-bird-assets-master/flappy-bird-assets-master/sprites/base.png').convert()
floor_animation = 0

bird_surface = pygame.image.load('C:/Users/cuerv/Downloads/flappy-bird-assets-master/flappy-bird-assets-master/sprites/bluebird-midflap.png').convert()
bird_rect = bird_surface.get_rect(center = (100,256))

pipe_surface = pygame.image.load('C:/Users/cuerv/Downloads/flappy-bird-assets-master/flappy-bird-assets-master/sprites/pipe-green.png').convert()
pipe_list = []
SPAWNPIPE = pygame.USEREVENT
pygame.time.set_timer(SPAWNPIPE,1200)

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()       
            sys.exit()
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_SPACE:
                bird_movement = 0
                bird_movement -= 7
                if event.type == SPAWNPIPE:
                    print("pipe")                   

    screen.blit(bg_surface, (0, 0))

    bird_movement += gravity
    bird_rect.centery += bird_movement
    screen.blit(bird_surface, (bird_rect))
    
    floor_animation -= 1
    draw_floor()
 
    if floor_animation <= -275:     #if floor = if the left surface is too to the left we are going to do soamething
        floor_animation = 0
    screen.blit(floor_surface, (floor_animation, 400))

    pygame.display.update()
    clock.tick(120)
1

There are 1 best solutions below

0
On BEST ANSWER

This occurs because your check of the SPAWNPIPE event is within the check of the KEYDOWN event. This can be solved with the following:

if event.type == pygame.KEYDOWN:
    if event.key == pygame.K_SPACE:
        bird_movement = 0
        bird_movement -= 7
if event.type == SPAWNPIPE:
    print("pipe")