Exemple #1
0
            break

        elif event.type == KEYDOWN:
            if event.key == K_UP:
                up = True

        elif event.type == KEYUP:
            if event.key == K_UP:
                up = False

    screen.blit(background, (0, 0))

    if (not dead):
        player.move(player_speed, up=up)

    player.render(screen, not up)

    for pipe in pipes:
        x, y = player.get_pos()
        x1, y1 = pipe.get_pos()

        if (player.get_collision(pipe)):
            die()

        elif (x > x1 and x < x1 + pipe.get_width() and timer > 40):
            score += 1
            timer = 0

        elif (x > x1 and x < x1 + pipe.get_width() and timer <= 40):
            timer += 1
Exemple #2
0
        elif event.type == KEYDOWN:
            if event.key == K_UP:
                up = True

        elif event.type == KEYUP:
            if event.key == K_UP:
                up = False


    screen.blit(background, (0,0) )

    if (not dead):
        player.move(player_speed, up = up)
    
    player.render(screen, not up)


    for pipe in pipes:
        x, y = player.get_pos()
        x1,y1= pipe.get_pos()
        
        if (player.get_collision(pipe)):
            die()

        elif (x > x1 and x < x1+pipe.get_width() and timer > 40):
            score += 1
            timer = 0

        elif (x > x1 and x < x1+pipe.get_width() and timer <= 40):
            timer += 1