Пример #1
0
def test_consumed():
    food = Food()
    food.consumed()
    assert food.location[0] < 600
    assert food.location[1] < 600
Пример #2
0
                snake.down()
            elif event.key == pygame.K_q:
                """Restart Game"""
                del snake
                snake = Snake()
                HUD.reset_score()
                spider.reset()

    screen.fill(WHITE)
    # --- Game logic
    if snake.alive:
        snake.simulate()
        spider.simulate()
        if snake.head_location == food.location:
            snake.eat()
            food.consumed()
            HUD.add_score(DIFFICULTY)
        if snake.head_location == spider.location:
            HUD.add_score(spider.score())
            snake.eat()
            spider.consumed()

    # --- Drawing
    if snake.alive:
        food.draw(screen)
        snake.draw(screen)
        spider.draw(screen)
        HUD.draw(screen)
    else:
        session_high_score = HUD.score if HUD.score > session_high_score else session_high_score
        font = pygame.font.Font('freesansbold.ttf', 32)