示例#1
0
def start_screen():
    intro_text = []

    fon = pygame.transform.scale(load_image('start.png'), (WIDTH, HEIGHT))
    screen.blit(fon, (0, 0))
    font = pygame.font.Font(None, 30)
    text_coord = 50
    for line in intro_text:
        string_rendered = font.render(line, True, pygame.Color('black'))
        intro_rect = string_rendered.get_rect()
        text_coord += 10
        intro_rect.top = text_coord
        intro_rect.x = 10
        text_coord += intro_rect.height
        screen.blit(string_rendered, intro_rect)
    clock = pygame.time.Clock()
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                terminate()
            elif event.type == pygame.KEYDOWN or \
                    event.type == pygame.MOUSEBUTTONDOWN:
                return  # начинаем игру
        pygame.display.flip()
        clock.tick(FPS)
示例#2
0
文件: game.py 项目: Lerasimuss/Game
def game():
    while True:  # Main Game Loop
        # чек кнопок
        #  pygame.time.delay(10)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                terminate()
            keys = pygame.key.get_pressed()
            if keys[pygame.K_SPACE] or keys[pygame.K_w]:  # Checks Jump
                person.jump()
        # чек смерти
        if person.is_dead:
            terminate()
        # рисует все остальное
        tiles.draw(screen)
        player.draw(screen)
        pygame.display.flip()
        person.update()
        screen.blit(bg, (0, 0))
示例#3
0
文件: tests.py 项目: Lerasimuss/Game
def check_next_ses(charar_x):
    if spike['x'] + spike['distanceApart'] * spike['amount'] < charar_x:
        return True
    return False


bg = load_image('fon.jpg')

while True:  # Main Game Loop
    pygame.time.delay(10)
    for i in range(spike['amount']):  # Spike Drawing
        triangleDraw(i)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            terminate()
        keys = pygame.key.get_pressed()
        if keys[pygame.K_SPACE] or keys[pygame.K_w]:  # Checks Jump
            jump()
    if check_next_ses(character['x']):
        nextSection()
    print_progress()
    for i in range(spike['amount']):  # Checks if death occurs
        if spike['x'] + spike['distanceApart'] * i <= character['x'] <= spike['x'] \
                + spike['distanceApart'] * i + spike['length']:

            posOnSpike = abs(character['x'] -
                             (spike['x'] + spike['length'] / 2))
            if posOnSpike * 2 + spike['y'] > character['y'] > spike['y'] \
                    or posOnSpike * 2 + spike['y'] > character['y'] + character['height'] > spike['y']:
                text_surface2 = font.render("YOU LOSE", False, (255, 0, 0))