Exemple #1
0
def new_game():
    from Graphic_Element import draw_graphic_elements
    Globals.do_new_game = False
    Gameboard.random_Gameboard()
    Score.Reset_Score()
    Globals.selected_element = (-1, -1)
    Gameboard.check_availible_moves()
    set_start_time()
    set_game_state(Globals.Game_State.ready)
    Graphic_Element.clear_graphic_elements()
    Seeds.reset()
    while not Globals.do_quit:
        update_ticks()
        Globals.clock.tick()
        Globals.screen.fill((0, 0, 0))
        draw_background()
        game_loop()
        for x in range(0, Gameboard.Gameboard_size):
            for y in range(0, Gameboard.Gameboard_size):
                obj = Gameboard.Gameboard[x][y]
                if (obj is not None):
                    obj.update()
                    obj.draw(x, y)
        if not Globals.selected_element == (-1, -1):
            element = get_selected_element()
            if element is not None:
                element.draw_box(Globals.selected_element)
        draw_score()
        Seeds.draw_seed_interface()
        if Globals.game_state != Globals.Game_State.game_over:
            draw_time_left()
        draw_graphic_elements(get_ticks())
        pygame.display.flip()
        Globals.clock.tick_busy_loop(60)
    Globals.do_quit = False
Exemple #2
0
def new_game():
    from Graphic_Element import draw_graphic_elements
    Globals.do_new_game = False
    Gameboard.random_Gameboard()
    Score.Reset_Score()
    Globals.selected_element = (-1, -1)
    Gameboard.check_availible_moves()
    set_start_time()
    set_game_state(Globals.Game_State.ready)
    Graphic_Element.clear_graphic_elements()
    Seeds.reset()
    while not Globals.do_quit:
        update_ticks()
        Globals.clock.tick()
        Globals.screen.fill((0,0,0))
        draw_background()
        game_loop()
        for x in range(0, Gameboard.Gameboard_size):
            for y in range(0, Gameboard.Gameboard_size):
                obj = Gameboard.Gameboard[x][y]                    
                if (obj is not None):
                    obj.update()
                    obj.draw(x, y)
        if not Globals.selected_element == (-1, -1):
            element = get_selected_element()
            if element is not None:
                element.draw_box(Globals.selected_element)
        draw_score()
        Seeds.draw_seed_interface()
        if Globals.game_state != Globals.Game_State.game_over:
            draw_time_left()
        draw_graphic_elements(get_ticks())
        pygame.display.flip()
        Globals.clock.tick_busy_loop(60)
    Globals.do_quit = False        
Exemple #3
0
def game_loop():
    if (get_ticks() >= Globals.end_time and Globals.game_state != Globals.Game_State.game_over):
        game_over()
    elif Globals.game_state == Globals.Game_State.ready:
        poll_events()
    elif Globals.game_state == Globals.Game_State.animation:
        do_animations()
    elif Globals.game_state == Globals.Game_State.update:
        if Gameboard.check_drop():
            set_game_state(Globals.Game_State.animation)
        elif not Gameboard.check_adjacency(Globals.match_length):
            set_game_state(Globals.Game_State.ready)
            Score.Reset_Combo()
            Globals.current_turn += 1
            if not Gameboard.check_availible_moves():
                Graphic_Element.make_graphic_element(
                    TextHandler.Render_TextBox("Shuffling Board",(255,255,255)), 250, 250, get_ticks() + 1000)
                reset_board()
    elif Globals.game_state == Globals.Game_State.game_over:
        poll_events()
Exemple #4
0
def game_loop():
    if (get_ticks() >= Globals.end_time
            and Globals.game_state != Globals.Game_State.game_over):
        game_over()
    elif Globals.game_state == Globals.Game_State.ready:
        poll_events()
    elif Globals.game_state == Globals.Game_State.animation:
        do_animations()
    elif Globals.game_state == Globals.Game_State.update:
        if Gameboard.check_drop():
            set_game_state(Globals.Game_State.animation)
        elif not Gameboard.check_adjacency(Globals.match_length):
            set_game_state(Globals.Game_State.ready)
            Score.Reset_Combo()
            Globals.current_turn += 1
            if not Gameboard.check_availible_moves():
                Graphic_Element.make_graphic_element(
                    TextHandler.Render_TextBox("Shuffling Board",
                                               (255, 255, 255)), 250, 250,
                    get_ticks() + 1000)
                reset_board()
    elif Globals.game_state == Globals.Game_State.game_over:
        poll_events()
Exemple #5
0
def game_over():
    Graphic_Element.make_graphic_element(
        TextHandler.Render_TextBox("Game Over", (255, 255, 255)), 250, 250, -1)
    set_game_state(Globals.Game_State.game_over)
Exemple #6
0
def game_over():
    Graphic_Element.make_graphic_element(
        TextHandler.Render_TextBox("Game Over",(255,255,255)), 250, 250, -1)
    set_game_state(Globals.Game_State.game_over)