Esempio n. 1
0
 def StartButton():
     button_width_factor = 0.18
     button_height_factor = 0.1
     Tool.Button(game_display, "START", display_width / 2 * 0.8,
                 display_height * 0.65, display_width * button_width_factor,
                 display_height * button_height_factor, Tool.green,
                 Tool.bright_green, StartGame)
Esempio n. 2
0
def Paused():
    global pause

    # Remove original button
    pygame.draw.rect(game_display, Tool.white,
                     (display_width * 0.7, display_height * 0.7,
                      display_width * 0.2, display_height * 0.1))
    pygame.draw.rect(game_display, Tool.white,
                     (display_width * 0.7, display_height * 0.85,
                      display_width * 0.2, display_height * 0.1))

    pause = True
    #pygame.draw.rect(game_display, red,[display_width*(0.7+0.0195*i) + 1, display_height*0.42 + 1, display_width * 0.02 - 2, display_height*0.06 - 2])
    large_text = pygame.font.Font("freesansbold.ttf", 115)
    text_surf, text_rect = Tool.TextObjects("Paused", large_text, Tool.red)
    text_rect.center = ((display_width * 0.6 / 2), (display_height * 0.4))

    while pause:
        game_display.blit(text_surf, text_rect)

        Tool.Button(game_display, "Continue", display_width * 0.05,
                    display_height * 0.7, display_width * 0.6 * 0.3,
                    display_height * 0.2, Tool.green, Tool.bright_green,
                    Unpause)
        Tool.Button(game_display, "Quit", display_width * 0.38,
                    display_height * 0.7, display_width * 0.6 * 0.3,
                    display_height * 0.2, Tool.red, Tool.bright_red, QuitGame)

        for event in pygame.event.get():
            Tool.CheckAltF4(event)
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE:
                    Unpause()

            if event.type == pygame.QUIT:
                QuitGame()

        pygame.display.update()
        clock.tick(15)
    game_display.blit(background_photo, [0, 0])
Esempio n. 3
0
def GraphicDisplay():
    """Moving objects display"""

    #stairs
    StairMoving()
    for i in range(8):
        stair = stair_list[i]
        if stair.type == "general":
            stair_photo = general_stair_photo
        elif stair.type == "hurt":
            stair_photo = hurt_stair_photo
        elif stair.type == "cloud":
            stair_photo = cloud_stair_photo
        elif stair.type == "moving":
            stair_photo = moving_stair_photo
        elif stair.type == "blackhole":
            stair_photo = blackhole_stair_photo
        game_display.blit(stair_photo, [stair.x, stair.y])

    # person & life
    global person
    for j in range(Tool.players):
        person = person_list[j]
        if person.blackhole_size != 0:
            game_display.blit(
                pygame.transform.scale(
                    person.photo, (Person.width - person.blackhole_size,
                                   Person.height - person.blackhole_size * 2)),
                [
                    person.x + person.blackhole_size // 2,
                    person.y - 5 + person.blackhole_size * 2
                ])
        else:
            game_display.blit(person.photo, [person.x, person.y - 5])

        life = person.life_count
        for i in range(life):
            pygame.draw.rect(game_display, Tool.red, [
                display_width *
                (0.7 + 0.0195 * i) + 1, display_height * 0.42 + 120 * j + 1,
                display_width * 0.02 - 2, display_height * 0.06 - 2
            ])
        for i in range(12 - life):
            pygame.draw.rect(game_display, Tool.white, [
                display_width * (0.7 + 0.0195 * (life + i)) + 1,
                display_height * 0.42 + 120 * j + 1, display_width * 0.02 - 2,
                display_height * 0.06 - 2
            ])

    # Current score
    pygame.draw.rect(game_display, Tool.white,
                     [display_width * 0.82, display_height * 0.2, 300, 60])

    game_font = pygame.font.Font('msjhbd.ttc', 48)
    title_name, title_rect = Tool.TextObjects(
        str(Score.Instance.current_score), game_font)
    title_rect.center = ((display_width * 0.85), (display_height * 0.25))
    title_rect.x = display_width * 0.82
    game_display.blit(title_name, title_rect)

    # Pause and Restart(Button)
    Tool.Button(game_display,
                "Pause!",
                display_width * 0.7,
                display_height * 0.7,
                display_width * 0.2,
                display_height * 0.1,
                Tool.green,
                Tool.bright_green,
                action=Paused)
    Tool.Button(game_display,
                "Restart!",
                display_width * 0.7,
                display_height * 0.85,
                display_width * 0.2,
                display_height * 0.1,
                Tool.red,
                Tool.bright_red,
                action=Restart)