Esempio n. 1
0
def drawSplash():
    # readFile()
    # Declaration of the application in which the menu is going to live.
    application = thorpy.Application(size=(500, 500), caption='ThorPy stupid Example')

    # Setting the graphical theme. By default, it is 'classic' (windows98-like).
    thorpy.theme.set_theme('human')

    # Declaration of some elements...
    global board
    useless1 = thorpy.make_button("This button is useless.\nAnd you can't click it.")

    text = "This button also is useless.\nBut you can click it anyway."
    useless2 = thorpy.Clickable.make(text)

    draggable = thorpy.Draggable.make("Drag me!")

    box1 = thorpy.make_ok_box([useless1, useless2, draggable])
    options1 = thorpy.make_button("Some useless things...")
    thorpy.set_launcher(options1, box1)

    inserter = thorpy.Inserter.make(name="Tip text: ",
                                    value="This is a default text.",
                                    size=(150, 20))

    file_browser = thorpy.Browser.make(path="C:/Users/", text="Please have a look.")

    browser_launcher = thorpy.BrowserLauncher.make(browser=file_browser,
                                                   const_text="Choose a file: ",
                                                   var_text="")

    color_setter = thorpy.ColorSetter.make()
    color_launcher = thorpy.ColorSetterLauncher.make(color_setter,
                                                     "Launch color setter")

    options2 = thorpy.make_button("Useful things")
    box2 = thorpy.make_ok_box([inserter, color_launcher, browser_launcher])
    thorpy.set_launcher(options2, box2)

    quit_button = thorpy.make_button("Quit")
    quit_button.set_as_exiter()

    central_box = thorpy.Box.make([options1, options2, quit_button])
    central_box.set_main_color((200, 200, 200, 120))
    central_box.center()

    # Declaration of a background element - include your own path!
    background = thorpy.Background.make(image=thorpy.style.EXAMPLE_IMG,
                                        elements=[central_box])

    menu = thorpy.Menu(elements=background, fps=45)
    menu.play()
Esempio n. 2
0
def launch_options(game, epause, mainmenu=False):
    els = get_options_elements()
    box = thorpy.make_ok_box(els)
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    box.center()
    m = thorpy.Menu(box)
    m.play()
    parameters.set_approx_memory_usage(els[6].get_value())
    parameters.MUSIC = els[2].get_value()
    if not parameters.MUSIC:
        pygame.mixer.music.stop()
    #
    parameters.REFLECT = els[9].get_value()
    hasclouds = els[10].get_value()
    parameters.RAIN_IMPACTS = els[11].get_value()
    if hasclouds:
        parameters.NCLOUDS = 5
    else:
        parameters.NCLOUDS = 0
    need_bisurf = hasclouds or parameters.RAIN_IMPACTS > 0 or parameters.REFLECT
    if need_bisurf != parameters.BISURFACE:
        print("Changing camera type", need_bisurf)
        parameters.BISURFACE = not (parameters.BISURFACE)
        if not mainmenu:
            game.refresh_camera()
    if not mainmenu:
        if need_bisurf and parameters.NCLOUDS == 0:
            game.cam.clouds = []
    if not mainmenu:
        game.cam.show(thorpy.get_screen())
        game.blit_things()
    epause.blit()
    pygame.display.flip()
Esempio n. 3
0
def launch_end():
    S = parameters.W
    screen = thorpy.get_screen()
    title_text = "The End"
    title = thorpy.make_text(title_text, thorpy.style.TITLE_FONT_SIZE, TCOLOR)
    text = "You are the first of the Intergalatic Ranking."
    end_text = "... You are free now."
    end_text = thorpy.pack_text(400, end_text)
    end = thorpy.make_text(end_text, thorpy.style.TITLE_FONT_SIZE, TCOLOR)
    letter = thorpy.make_text(thorpy.pack_text(int(0.7 * S), text))
    w = letter.get_fus_rect().w + 10
    boxletter = thorpy.Box.make([letter], (w, S // 2))
    boxletter.refresh_lift()
    thorpy.style.BOX_RADIUS += 10
    background = thorpy.load_image("PaulinaRiva.png")
    background = thorpy.get_resized_image(background,
                                          (parameters.W, parameters.H // 2),
                                          type_=max)
    ##    background = thorpy.Background.make(image=background)
    thorpy.get_screen().blit(background, (0, 0))
    pygame.display.flip()
    box = thorpy.make_ok_box([title, boxletter, end], "Ok")
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    boxletter.set_main_color((200, 200, 200, 50))
    box.set_main_color((200, 200, 255, 100))
    box.center()
    thorpy.style.BOX_RADIUS -= 10
    launch(box)
def launch_ingame_options():
    thorpy.set_theme("classic")

    def func():
        parameters.scene.refresh_display()
        box.blit()
        pygame.display.flip()

    e, varset = get_display_options()
    e2 = thorpy.make_button("Show help", scenario.launch_help, {"func": func})

    def leave():
        if thorpy.launch_binary_choice("Are you sure?"):
            parameters.scene.abandon = True
            thorpy.functions.quit_menu_func()
        func()

    q = thorpy.make_button("Abandon", leave)
    box = thorpy.make_ok_box(
        [thorpy.make_text("Pause"),
         thorpy.Line.make(100, "h"), e, e2, q])
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    ##    boxletter.set_main_color((200,200,200,50))
    box.set_main_color((200, 200, 255, 200))
    box.center()
    scenario.launch(box)
    parameters.scene.cam.set_aa(varset.get_value("aa"))
    parameters.VISIBILITY = varset.get_value("visibility")
    thorpy.set_theme(parameters.THEME)
Esempio n. 5
0
def choose_name():
    name = thorpy.Inserter.make("Choose your name", value="Hero")
    box = thorpy.make_ok_box([name])
    thorpy.auto_ok(box)
    box.center()
    thorpy.launch_blocking(box)
    parameters.PNAME = name.get_value()
Esempio n. 6
0
def launch_intro_text2():
    S = parameters.W
    screen = thorpy.get_screen()
    title_text = "The beginning (2)"
    title = thorpy.make_text(title_text, thorpy.style.TITLE_FONT_SIZE, TCOLOR)
    end_text = "... My only hope now is to become the greatest racer.."
    end_text = thorpy.pack_text(400, end_text)
    end = thorpy.make_text(end_text, thorpy.style.TITLE_FONT_SIZE, TCOLOR)
    letter = thorpy.make_text(thorpy.pack_text(int(0.7 * S), INTRO2))
    w = letter.get_fus_rect().w + 10
    boxletter = thorpy.Box.make([letter], (w, S // 2))
    boxletter.refresh_lift()
    thorpy.style.BOX_RADIUS += 10
    background = thorpy.load_image("PaulinaRiva.png")
    background = thorpy.get_resized_image(background,
                                          (parameters.W, parameters.H // 2),
                                          type_=max)
    ##    background = thorpy.Background.make(image=background)
    thorpy.get_screen().blit(background, (0, 0))
    pygame.display.flip()
    box = thorpy.make_ok_box([title, boxletter, end], "Ok")
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    boxletter.set_main_color((200, 200, 200, 50))
    box.set_main_color((200, 200, 255, 100))
    box.center()
    thorpy.style.BOX_RADIUS -= 10
    launch(box)
Esempio n. 7
0
def get_intro_text():
    image = thorpy.load_image("message_in_a_bottle_by_solid_pawn.png")
    image = pygame.transform.scale(image, (parameters.S,parameters.S))
    title_text = "Dear friend,\nA few years ago, I found a message in a bottle near the sea...\n"
    title = thorpy.make_text(title_text, thorpy.style.TITLE_FONT_SIZE, gui.TCOLOR)
    text = "At that time, I was working hard on that famous Topological Astronomy Problem and I began to inattentively read the message..."+\
            "But to my great surprise, it appeared that the author of the letter, a certain Gottfried Perigeo,"+\
            " was trying to complete a mad - though so brave! - travel around the world, following West-East axis, almost one century ago.\n\n"+\
            "    Except the fact that the poor explorer sent a desperate SOS message that was obviously received hundred year too late,"+\
            " my interest was peaked by the singular axis he was travelling. Here the story joins the Topological Astronomy Problem.\n\n"+\
            "    Indeed, my dear friend, I was - and I'm still - one of the rare physicists to believe that the world has the topology of a torus"+\
            " (explain uneducated people that it's like donut). Despite several celestial hints, most of my colleagues give no credit in this theory, and invest"+\
            "all their energy in proving that our planet is spherical. The situation was the same during Perigeo's life ; since the famous"+\
            "explorer Girato Settentrio completed the South-North around the world travel, it was clear that Gottfried Perigeo thought the planet"+\
            "is a torus , otherwise the travel he initiated was a suicide, because of the absolute extreme difficulty of the West-East round trip, if it exists.\n\n"+\
            "    I know you trust in my science, my friend, and I have to admit you are one of the few ones. Here is my demand:\n"+\
            "Take all my money. Buy ship, hire mens, prepare a big exploration trip. Find Perigeo's shipwreck, pursue his travel, and finish what he began. Bring back with you a keepsake of Perigeo. He deserves it.\n"+\
            "\n        You cannot let him in here."
    end_text = "Prove the world that our planet is toroidal!"
    end = thorpy.make_text(end_text, thorpy.style.TITLE_FONT_SIZE, gui.TCOLOR)
    letter = thorpy.make_text(thorpy.pack_text(int(0.7*parameters.S),text))
    w = letter.get_fus_rect().w + 10
    boxletter = thorpy.Box.make([letter],(w,parameters.S//2))
    boxletter.set_main_color((200,200,255,50))
    boxletter.refresh_lift()
    thorpy.style.BOX_RADIUS += 10
    box = thorpy.make_ok_box([title,boxletter,end],"Accept")
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    box.set_main_color((200,200,255,80))
    box.center()
    background = thorpy.Background(image=image,elements=[box])
    thorpy.style.BOX_RADIUS -= 10
    return background
Esempio n. 8
0
def get_instructions():
    title = thorpy.make_text("Instructions", thorpy.style.TITLE_FONT_SIZE,
                                gui.TCOLOR)
    perig_coord = (Vector2(parameters.WRECK_COORD)*parameters.S)//10
    cordtext = "Coordinates of Gottfried Perigeo's wreckage: not far from"+str(perig_coord)
    ecoord = make_instruction(cordtext)
    #
    jtext = "Journal: Press J to open crew's logbook. It lists a lot of events, and allow you to add entries."
    ejournal = make_instruction(jtext)
    #
    ftext = "Flags: You have "+str(parameters.MAX_FLAGS)+" flags at your disposal to help you locate. Press F to plant a flag on the ground. You can remove flags. Flags automatically add entries in logbook."
    eflag = make_instruction(ftext)
    #
    stext = "Seasons: Seasons change the terrain and the temperatures. Season change are every "+str(parameters.SEASON_MOD_DAYS)+" day from day zero."
    eseason = make_instruction(stext)
    #
    foodtext = "Food: Crew has to eat in order to survive. Remaining food is schematized by a gauge on the right. Low temperature result in higher demand in food. "+\
                "Ship can carry a limited amount of food, as well as the crew when walking. You can store food from/into villages and camps. You can obtain food by hunting."
    efood = make_instruction(foodtext)
    #
    huntext = "Hunting: Crew members are able to hunt if there are arrows in your stock. Sucessful hunting refill your food bar. The chance to find food depends on the temperature and the skills of the best hunter in your crew."
    ehunt = make_instruction(huntext)
    #
    vtext = "Village: Villages contains and produce food along the year. You can exchange food with villages by pressing E. However, villages become more rare as you go far from civilization."
    evillage = make_instruction(vtext)
    #
    camptext = "Camp: You can camp/uncamp by pressing C. You have "+str(parameters.MAX_CAMPS)+" camps at your disposal. You need a camp to hunt and to wait. As for villages, you can exchange food with camps."
    ecamp = make_instruction(camptext)
    #
    wtext = "Weather: Altitude influe temperature. Wind is schematized by a line over the compass. Wind moves the ship. Sometimes, violent storms can appear."
    eweather = make_instruction(wtext)
    #
    #
    waitext = "Waiting: You can wait for a chosen duration (in days) if you are in a camp. Crew still consume food during waiting. Waiting will be stopped if food level reaches zero. Press P."
    ewait = make_instruction(waitext)
    #
    #
    cannibalismtext = "Cannibalism: In extreme situations, you may take serious decisions... If your food level is null, press X to choose a crew member to eat."
    ecannibal = make_instruction(cannibalismtext)
    #
    #
    oasistext = "Oasis: During summer, you can find food in oasises."
    eoasis = make_instruction(oasistext)
    #
    #
    foresttext = "Forest: hunting near a forest increases by 20 percent your chances of finding food, in any season." #not really true
    eforest = make_instruction(foresttext)
    #
    elements = [ecoord,efood,ehunt,eoasis,eforest,ejournal,evillage,ecamp,eflag,eseason,eweather,ecannibal,ewait,]
    thorpy.style.BOX_RADIUS += 10
    boxletter = thorpy.Box.make(elements,(int(0.9*parameters.S),int(0.8*parameters.S)))
    boxletter.refresh_lift()
    box = thorpy.make_ok_box([title,boxletter])
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    box.set_main_color((200,200,255))
    box.center()
    thorpy.style.BOX_RADIUS -= 10
    return box
Esempio n. 9
0
def launch_help(func=None):
    S = parameters.W
    title = thorpy.make_text("Instructions", thorpy.style.TITLE_FONT_SIZE,
                             TCOLOR)
    elements = []
    #
    text = "SPACE BAR : Accelerate (this uses fuel)"
    elements.append(make_instruction(text))
    text = "LEFT/RIGHT/UP/DOWN : Change way (turn left/right/up/down)"
    elements.append(make_instruction(text))
    text = "Race: The goal of a race is to reach the finish line as fast as possible.\n"+\
            "If your vessel is destructed or if you cannot reach the finish line, you loose the race."
    elements.append(make_instruction(text))
    text = "Obstacles: Obstacles are on the track. Some of them can move and rotate. Obstacles damage your vessel and slow it down."
    elements.append(make_instruction(text))
    text = "Vessel: A vessel is constituted of a nose, a cockpit, a tail, two wings and one engine.\n"+\
            "These parts determine how fast the vessel can run, how well it turns and how resistant it is to obstacles."
    elements.append(make_instruction(text))
    text = "Life: The current damage state of your vessel in indicated on the top-left of the HUD. "+\
            "The more you damage your vessel, the more you will pay for repairing it."
    elements.append(make_instruction(text))
    text = "Garage: You prepare the next race in your garage. You can buy/sell parts and modify/repair your vessel."
    elements.append(make_instruction(text))
    text = "Ranking: The Intergalactic Ranking works as follow - the winner of each race wins a point and the loser loses one point.\n"+\
            "The Intergalactif League is subdivided in three categories: national, international and intergalactic. "+\
            "Note that the money prize of each race is determined by the category."
    elements.append(make_instruction(text))
    #
    thorpy.style.BOX_RADIUS += 10
    boxletter = thorpy.Box.make(elements,
                                (int(0.75 * S), int(0.85 * parameters.H)))
    boxletter.refresh_lift()
    box = thorpy.make_ok_box([title, boxletter])
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    ##    boxletter.set_main_color((200,200,200,50))
    box.set_main_color((200, 200, 255, 100))
    box.center()
    thorpy.style.BOX_RADIUS -= 10
    background = thorpy.load_image("PaulinaRiva.png")
    background = thorpy.get_resized_image(background,
                                          (parameters.W, parameters.H // 2),
                                          type_=max)
    ##    background = thorpy.Background.make(image=background)
    thorpy.get_screen().blit(background, (0, 0))
    pygame.display.flip()
    launch(box)
    if func:
        func()
Esempio n. 10
0
 def __init__(self, helps):
     """helps is a list of tuple on the form (title, list_of_help_texts)."""
     elements = []
     for title, texts in helps:
         e_title = guip.get_title(title)
         e_line = thorpy.Line.make(e_title.get_fus_size()[0])
         e_helps = []
         for h in texts:
             e_helps.append(get_help_text_normal(*h))
         elements += [e_line, e_title] + e_helps
     self.e = thorpy.make_ok_box(elements)
     self.b = thorpy.Element.make(size=thorpy.functions.get_screen_size())
     self.b.set_main_color((200, 200, 200, 100))
     self.e.center()
     self.launcher = thorpy.make_button("See commands", self.launch)
Esempio n. 11
0
 def get_stats(self):
     stats = self.game.stats.get()
     elements = [
         thorpy.make_text("Trip Statistics", thorpy.style.TITLE_FONT_SIZE,
                          TCOLOR),
         thorpy.Line.make(200, "h")
     ]
     for title, value, post in stats:
         value = " : " + str(round(value, 1))
         elements.append(thorpy.make_text(title + value + " " + post))
     box = thorpy.make_ok_box(elements)
     box.e_ok.user_func = thorpy.functions.quit_menu_func
     box.e_ok.user_params = {}
     box.center()
     return box
Esempio n. 12
0
def launch_end_text(score):
    screen = thorpy.get_screen()
    title_text = "The End - Score : " + str(score) + " days"
    title = thorpy.make_text(title_text, thorpy.style.TITLE_FONT_SIZE, gui.TCOLOR)
    text = "Your expedition was a success. After that long trip, you are back to civilization. "+\
            " Perigeo's compass and seals were undoubtedly recognizable, and their memory will now be teached at school."
    end_text = "Regarding yourself and your crew, you will be recorded in the centuries to come as the first to complete a round aroud the world.\n"+\
    " Which has been proven to be a torus."
    end_text = thorpy.pack_text(400,end_text)
    end = thorpy.make_text(end_text, thorpy.style.TITLE_FONT_SIZE, gui.TCOLOR)
    letter = thorpy.make_text(thorpy.pack_text(int(0.7*parameters.S),text))
    w = letter.get_fus_rect().w + 10
    boxletter = thorpy.Box.make([letter],(w,parameters.S//2))
    boxletter.refresh_lift()
    thorpy.style.BOX_RADIUS += 10
    box = thorpy.make_ok_box([title,boxletter,end],"Quit")
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    box.set_main_color((200,200,255))
    box.center()
    thorpy.style.BOX_RADIUS -= 10
    launch(box)
Esempio n. 13
0
def launch_perigeo_text():
    screen = thorpy.get_screen()
    title_text = "Dear visitor,\nI apologize for the welcome, which could have been warmer...\n"
    title = thorpy.make_text(title_text, thorpy.style.TITLE_FONT_SIZE, gui.TCOLOR)
    text = "But the crew's death does not help. I tried my best to prove that the world is toroidal."+\
    " According to the theory, my ship has gone beyond the half-perimeter, and we still did not recognize any of the landscapes"+\
    " that some of us saw as members of former Settentrio's expeditions. As a result, I am convinced of the toroidal nature of the world."+\
    " As a proof of my presence so far on the East - well, it is actually the West side of the world now - let my bones on the wild. But..."
    end_text = "... bring my compass and my seal back to civilization, and show them that I was right.\n          Gottfried Perigeo"
    end_text = thorpy.pack_text(400,end_text)
    end = thorpy.make_text(end_text, thorpy.style.TITLE_FONT_SIZE, gui.TCOLOR)
    letter = thorpy.make_text(thorpy.pack_text(int(0.7*parameters.S),text))
    w = letter.get_fus_rect().w + 10
    boxletter = thorpy.Box.make([letter],(w,parameters.S//2))
    boxletter.refresh_lift()
    thorpy.style.BOX_RADIUS += 10
    box = thorpy.make_ok_box([title,boxletter,end],"Accept")
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    box.set_main_color((200,200,255))
    box.center()
    thorpy.style.BOX_RADIUS -= 10
    launch(box)
Esempio n. 14
0
def game_parameters_menu():
    writing()
    # VARSET
    varset = thorpy.VarSet()
    varset.add("difficulty", ["easy", "medium", "hard"], text="Difficulty:")
    varset.add("worldx",
               value=str(parameters.WORLD_SIZE[0]),
               text="World X-size:",
               limits="int")
    varset.add("worldy",
               value=str(parameters.WORLD_SIZE[1]),
               text="World Y-size:",
               limits="int")
    varset.add("seasonmod",
               value=parameters.SEASON_MOD_DAYS,
               text="Season duration (days):",
               limits=(6, 100))
    varset.add("seed",
               value=str(np.random.randint(0, 1000000)),
               text="Seed:",
               limits="int")
    ps = thorpy.ParamSetter.make([varset])
    #
    title = thorpy.make_text("Game parameters",
                             font_size=thorpy.style.FONT_SIZE + 3,
                             font_color=TCOLOR)
    line = thorpy.Line.make(100, "h")
    elements = [title, line, ps]
    box = thorpy.make_ok_box(elements)
    box.center()
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    m = thorpy.Menu([box])
    m.play()
    ps.save()
    playing()
    return varset
Esempio n. 15
0
#Declaration of the application in which the menu is going to live.
application = thorpy.Application(size=(500, 500),
                                 caption='ThorPy stupid Example')

#Setting the graphical theme. By default, it is 'classic' (windows98-like).
thorpy.theme.set_theme('human')

#Declaration of some elements...
useless1 = thorpy.Element("This button is useless.\nAnd you can't click it.")

text = "This button also is useless.\nBut you can click it anyway."
useless2 = thorpy.Clickable(text)

draggable = thorpy.Draggable("Drag me!")

box1 = thorpy.make_ok_box([useless1, useless2, draggable])
options1 = thorpy.make_button("Some useless things...")
thorpy.set_launcher(options1, box1)

inserter = thorpy.Inserter(name="Tip text: ",
                           value="This is a default text.",
                           size=(150, 20))

file_browser = thorpy.Browser(path="C:/Users/", text="Please have a look.")

browser_launcher = thorpy.BrowserLauncher(browser=file_browser,
                                          const_text="Choose a file: ",
                                          var_text="")

color_setter = thorpy.ColorSetter.make()
color_launcher = thorpy.ColorSetterLauncher(color_setter,
Esempio n. 16
0
botao_parar_cr.set_font_size(18)
botao_parar_cr.set_size((100, 50))
botao_parar_cr.set_main_color((255, 100, 100))
pasta_cr = thorpy.Inserter(name="Nome da pasta de destino:")

#Reacoes Controle Remoto
reacao_pasta_cr = thorpy.Reaction(reacts_to=thorpy.constants.THORPY_EVENT,
                                  reac_func=pasta_destino_cr,
                                  event_args={
                                      "id": thorpy.constants.EVENT_INSERT,
                                      "el": pasta_cr
                                  })

#Launcher do modo controle remoto
caixa_cr = thorpy.make_ok_box([
    titulo_cr, inv4, texto_cr, inv5, botao_iniciar_cr, inv6, botao_parar_cr,
    inv7, pasta_cr, inv8
])
caixa_cr.set_main_color((200, 220, 230))
caixa_cr.fit_children(margins=(20, 20))
caixa_cr.add_reaction(reacao_pasta_cr)
botao_cr = thorpy.make_button("Controle Remoto")
botao_cr.set_font_size(17)
botao_cr.set_font_color((40, 40, 40))
botao_cr.set_size((200, 50))
botao_cr.set_main_color((230, 230, 215))
thorpy.set_launcher(botao_cr, caixa_cr)

#Elementos do modo time-lapse
titulo_tl = thorpy.make_text("Modo Time-Lapse", 24, (40, 40, 40))
texto_tl = thorpy.make_text(
    "'Iniciar' - Ativar o modo de time-lapse\n'Parar' - Desativar o modo de time-lapse",
Esempio n. 17
0
thorpy.set_launcher(button1, my_element, click_quit=True)

# ****************** Second launcher : button 2 ******************
#here the element to be launched is a box with ok and cancel buttons + custom
#elements. We can also use make_ok_box, with only 1 text.
#Note that DONE_EVENT and CANCEL_EVENT are posted accordingly at unlaunch.
box = thorpy.make_ok_cancel_box([thorpy.make_button(str(i)) for i in range(8)],
                                 ok_text="Ok", cancel_text="Cancel")
button2 = thorpy.make_button("Launcher 2")
thorpy.set_launcher(button2, box)

# ****************** Third launcher : button 3 ******************
#This launcher launches a box, set it green, and changes screen color when
#unlaunched.
button3 = thorpy.make_button("Launcher 3")
other_box = thorpy.make_ok_box([thorpy.make_text("Color is gonna change...")])
my_launcher = thorpy.set_launcher(button3, other_box)#this time get the launcher
#we specify some custom operations that have to be done before/after launching:
def my_func_before():
    my_launcher.launched.set_main_color((0,255,0)) #change launched box color
    my_launcher.default_func_before() #default stuff
def my_func_after():
    background.set_main_color((0,100,100)) #change background color
    my_launcher.default_func_after() #default stuff

my_launcher.func_before = my_func_before
my_launcher.func_after = my_func_after

# ****************** Fourth launcher : event ******************
#This launcher is not linked to a ThorPy element, but instead user can activate
#it by pressing SPACE
Esempio n. 18
0
def get_options():
    els = get_options_elements()
    box = thorpy.make_ok_box(els)
    return thorpy.make_launcher(box, "Options"), els[6]
Esempio n. 19
0
 def __init__(self, game, time_remaining=-1):
     game.update_loading_bar("Building gui elements", 0.95)
     self.game = game
     game.gui = self
     #
     self.font_colors_mat = {}
     for m in self.game.me.materials:
         n = m.lower()
         if "snow" in n or "sand" in n:
             self.font_colors_mat[m] = (0, ) * 3
         else:
             self.font_colors_mat[m] = (255, ) * 3
     #
     self.surface = thorpy.get_screen()
     game.me.cam.ui_manager = self
     self.me = game.me
     self._debug = True
     self.enhancer = GuiGraphicsEnhancement(
         self,
         zoom=0,  #work only for a given zoom level
         splashes=True,
         footprints=True)
     #
     self.last_destination_score = {}
     self.destinations_mousemotion = []
     self.destinations_lmb = []
     self.forced_gotocell = False
     self.selected_unit = None
     self.cell_under_cursor = None
     self.blue_highlights = []
     self.red_highlights = []
     #
     self.color_dest_lmb = (255, 0, 0)
     self.color_dest_mousemotion = (255, 255, 0)
     self.dest_alpha_amplitude = 20
     self.dest_alpha0 = 100
     self.dest_period = self.me.lm.nframes * 3.
     self.dest_omega = 2. * math.pi / self.dest_period
     #
     self.e_cant_move = guip.get_infoalert_text("Can't go there")
     self.e_cant_move_another = guip.get_infoalert_text(
         "Another unit is already going there")
     self.e_wrong_team = guip.get_infoalert_text(
         "You cannot command another player's units")
     self.e_already_moved = guip.get_infoalert_text(
         "This unit has already moved in this turn")
     #
     self.moving_units = []
     self.add_reactions()
     self.life_font_size = guip.NFS
     self.life_font_color = (255, 255, 255)
     self.font_life = pygame.font.SysFont(guip.font_gui_life,
                                          self.life_font_size)
     self.show_lifes = True
     self.interaction_objs = []
     #
     #here you can add/remove buttons to/from the menu
     e_options = thorpy.make_button("Options", self.show_options)
     e_save = thorpy.make_button("Save", io.ask_save, {"me": self.me})
     e_load = thorpy.make_button("Load", io.ask_load)
     e_quit = thorpy.make_button("Quit game", quit_func)
     self.menu = thorpy.make_ok_box(
         [get_help_box().launcher, e_options, e_save, e_load, e_quit])
     self.menu.center()
     self.set_map_gui()
     e_ap_cancel_move = elements.get_infoalert_text(
         "To cancel last move, press", "<RETURN>")
     self.me.alert_elements.append(e_ap_cancel_move)
     self.me.ap.add_alert_countdown(e_ap_cancel_move,
                                    guip.DELAY_HELP * self.me.fps)
     self.has_moved = []
     #
     self.e_add = {
         key: thorpy.make_button("+")
         for key in ["left", "right", "top", "down"]
     }
     self.e_rem = {
         key: thorpy.make_button("-")
         for key in ["left", "right", "top", "down"]
     }
     self.last_move = None
Esempio n. 20
0
    def play():
        ##        if not DEBUG:
        if True:
            name = thorpy.Inserter.make("Choose your name", value="Hero")
            box = thorpy.make_ok_box([name])
            thorpy.auto_ok(box)
            box.center()
            ##        scenario.launch(box)
            thorpy.launch_blocking(box, e_bckgr)
            parameters.HERO_NAME = name.get_value()

            tit = thorpy.make_text("Choose vessel color")
            color = thorpy.ColorSetter.make("Choose vessel color")
            box = thorpy.make_ok_box([tit, color])
            thorpy.auto_ok(box)
            box.center()
            ##        scenario.launch(box)
            thorpy.launch_blocking(box)
            parameters.HERO_COLOR = color.get_value()
            print("setting", parameters.HERO_COLOR)
            #
            vc = gamelogic.ShowRanking("Choose a vessel", "Continue", [],
                                       False, True)
            vc.derotate()
            thorpy.set_theme("classic")
            if not DEBUG:
                scenario.launch_intro_text()
                scenario.launch_intro_text2()
                scenario.launch_help()
        thorpy.set_theme(parameters.THEME)
        init_game(vc.vessels[0])
        parameters.AA = vs.get_value("aa")
        parameters.VISIBILITY = vs.get_value("visibility")

        while True:
            parameters.flush()
            while True:
                scene, goback = init_scene()
                if not goback:
                    break
            reac = thorpy.ConstantReaction(thorpy.THORPY_EVENT,
                                           scene.func_time,
                                           {"id": thorpy.constants.EVENT_TIME})
            g = thorpy.Ghost.make()
            parameters.ghost = g
            g.add_reaction(reac)
            thorpy.functions.playing(30, 1000 // parameters.FPS)
            m = thorpy.Menu(g, fps=parameters.FPS)
            m.play()
            gamelogic.refresh_ranking()
            cat_before, c1 = gamelogic.get_category(parameters.player.ranking -
                                                    1)
            sr = gamelogic.ShowRanking("Ranking",
                                       "Go to garage",
                                       scene.get_current_ranking_players(),
                                       results=True)
            gamelogic.refresh_ranking()
            sr.derotate()
            cat_after, c2 = gamelogic.get_category(parameters.player.ranking -
                                                   1)
            if c2 > c1:
                thorpy.launch_blocking_alert("Your category is now "+cat_after+\
                    "!\nCongratulations, "+parameters.HERO_NAME+".\nYou earned an extra bonus of 500 $."+\
                    "\n\nThe track length in this category is 1000m longer.")
                parameters.player.money += 500
                parameters.ZFINISH += 1000
                ##                parameters.ENGINE_POWER += 0.005
                parameters.CURRENT_QUALITY += 0.5
            elif c2 < c1:
                thorpy.launch_blocking_alert("Your category is now "+cat_after+\
                    "!\nThis is very deceptive, "+parameters.HERO_NAME+".\n\n"+\
                    "The track length in this category is 1000m shorter.")
                parameters.ZFINISH -= 1000
                parameters.CURRENT_QUALITY -= 0.5
            parameters.flush()
            if parameters.player.ranking == parameters.players[0].ranking:
                scenario.launch_end()
            if parameters.player.vessel.life <= 0:
                parameters.player.vessel.life = 1
                parameters.player.vessel.visible = True
            if random.random() < parameters.MERCHANT_PROBABILITY:
                garage.buy_part(None)
Esempio n. 21
0
def func_reac_time(): #here add wathever you want
    """Function called each frame"""
    me.func_reac_time()
    pygame.display.flip()
thorpy.add_time_reaction(me.e_box, func_reac_time)

#here you can add/remove buttons to/from the menu
def quit_func():
    io.ask_save(me)
    thorpy.functions.quit_func()
e_quit = thorpy.make_button("Quit game", quit_func)
e_save = thorpy.make_button("Save", io.ask_save, {"me":me})
e_load = thorpy.make_button("Load", io.ask_load)

launched_menu = thorpy.make_ok_box([ me.help_box.launcher,
                                            e_save,
                                            e_load,
                                            e_quit])
launched_menu.center()
me.menu_button.user_func = thorpy.launch_blocking
me.menu_button.user_params = {"element":launched_menu}

#me.e_box includes many default reactions. You can remove them as follow:
#remove <g> key:
##me.e_box.remove_reaction("toggle grid")
#remove arrows keys, replacing <direction> by left, right, up or down:
##me.e_box.remove_reaction("k <direction>")
#remove +/- numpad keys for zoom, replacing <sign> by plus or minus:
##me.e_box.remove_reaction("k <sign>")
#remember to modify/deactivate the help text corresponding to the removed reac