为什么我没有收到打印消息?

时间:2020-08-07 05:47:50

标签: python printing pygame

 while running:
        screen.fill((255,255,255))

        screen.blit(background,(0,0))   
        
        for event in pygame.event.get():

            if event.type == pygame.QUIT:
                running = False


# keystroke controlling   i am not getting this print message 

            if event.type == pygame.KEYDOWN:
                if event.type == pygame.K_SPACE:

                    print("space is pressed ")

            if event.type == pygame.KEYUP:

                if event.type == pygame.K_SPACE:

                    print("released")
                                 
        
        playerx += playerx_change
        player(playerx , playery)
        cactus(cactusx , cactusy)
        pygame.display.update()

game()

1 个答案:

答案 0 :(得分:2)

这是因为event.type不能同时是KEYUP和K_SPACE。 将代码重写为:

UPDATE BATCH set batch_typ =
case when batch_typ = 'BLUE' then 'GREEN'
     when batch_typ = 'GREEN' then 'BLUE' end;

````````````````