Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
 def fill_buttons_list(self):
     thorpy.set_theme("round")
     for text, button_function in self.b_info.items():
         button_to_add = thorpy.make_button(text, button_function)
         button_to_add.set_font_size(20)
         button_to_add.scale_to_title()
         self.buttons.append(button_to_add)
Ejemplo n.º 3
0
 def initialize(self, screen):
     self.screen = screen
     self.difficulty = "normal"
     thorpy.set_theme('human')
     thorpy.style.MARGINS = (10,10)
     self.elements = []
     self.restart = False
     self.running = True
Ejemplo n.º 4
0
def main():
    pygame.init()
    thorpy.set_theme('human')
    width = 600
    height = 600
    font = pygame.font.SysFont("Arial", 18)
    screen, background = window_init(width, height, "Minesweeper!")
    main_menu = MainMenu(None, screen, background, font)
    main_menu.activate()
Ejemplo n.º 5
0
 def create_menu(self):
     self.background_image()
     thorpy.set_theme("round")
     b_text = ["Start Game", "Load Game", "Instructions", "Quit"]
     buttons = [
         thorpy.make_button(txt, func=self.menu_func[txt]) for txt in b_text
     ]
     [button.set_font_size(30) for button in buttons]
     [button.scale_to_title() for button in buttons]
     self.menu_box = thorpy.Box(buttons)
     menu = thorpy.Menu(self.menu_box)
     self.proper_display(menu, self.menu_box)
     pg.display.update()
     return menu
Ejemplo n.º 6
0
    def create_load_menu(self):
        self.background_image()
        thorpy.set_theme("round")
        games = self.network.send(["get_games_to_load"])
        self.load_buttons = [
            thorpy.make_button(str(game),
                               func=self.load_game,
                               params={
                                   "which_game": i,
                                   "games": games
                               }) for i, game in enumerate(games)
        ]
        self.load_buttons.append(
            thorpy.make_button("Quit", func=self.quit_submenu))
        [button.set_font_size(20) for button in self.load_buttons]
        [button.scale_to_title() for button in self.load_buttons]
        self.load_box = thorpy.Box(self.load_buttons)
        load_submenu = thorpy.Menu(self.load_box)

        return load_submenu
Ejemplo n.º 7
0
##SEED = 800
SEED = 66
##SEED = 0

S = terrain.S
parameters.set_S(S)


METADATA_PATH = "./metadata" #create a file for storing data on application
mdm = thorpy.MetaDataManager()
mdm.read_data(METADATA_PATH)
app = thorpy.Application((S,S))
mdm.load_font_data(METADATA_PATH)
gui.show_loading()
gui.playing() #set key delay
thorpy.set_theme("human")
screen = thorpy.get_screen()
e_bckgr = thorpy.Ghost.make()
sound.play_random_music()
terrain.cache()

savefile=gui.launch_main_menu() #xxx
climate = terrain.Climate(0)

if savefile:
    gui.show_loading()
    sm = savemanager.SaveManager(savefile)
    SEED = int(sm.d["cam"]["seed"])
    sm.load_parameters()

Camtype=parameters.get_camera_type()
Ejemplo n.º 8
0
buttons[0].set_main_color(
    (0, 255, 0))  #slow method, to be used outside of a loop
buttons[1].set_main_color((0, 255, 0, 100))  #with alpha value this time
buttons[2].set_font_color(
    (255, 255, 0))  #slow method, to be used outside of a loop
buttons[3].set_font_color_hover((0, 255, 0))  #...
buttons[4].set_font("century")  #may not work on your computer
buttons[5].set_font_size(18)
buttons[5].scale_to_title()
buttons[6].set_size((100, 100))
buttons[7].set_text("First line\nSecond line")
buttons[7].scale_to_title()

#use predefined theme
for theme_name in ["classic", "round", "human", "simple", "windows10"]:
    thorpy.set_theme(theme_name)
    button = thorpy.make_button("Theme name : " + theme_name)
    button.scale_to_title()
    buttons.append(button)
    thorpy.theme.set_default_theme_as_current()

#A customized style
a_round_button = thorpy.Clickable("Custom round Button")
painter = thorpy.painters.optionnal.human.Human(size=(200, 30),
                                                radius_ext=0.5,
                                                radius_int=0.4,
                                                border_color=(0, 0, 255),
                                                color=(100, 100, 255))
a_round_button.set_painter(painter)
a_round_button.finish()
buttons.append(a_round_button)
Ejemplo n.º 9
0
import thorpy

application = thorpy.Application(size=(500, 500))

thorpy.set_theme("round")


def launch_menu(choices):
    title = thorpy.make_text("Choose something", 14, (255, 0, 0))

    #now define the behaviour of clicked elements
    def at_press(what):
        some_text.set_text(what)  #change the element content (see below)
        thorpy.functions.quit_menu_func()  #exit the menu
        thorpy.store(background)  #align the elements (size has changed)
        background.unblit_and_reblit()

    #dynamically create elements
    elements = []
    for text in choices:
        element = thorpy.make_button(text, func=at_press)
        element.user_params = {"what": text}
        elements.append(element)
    #box to store everything
    box = thorpy.Box([title] + elements)
    box.set_main_color((200, 200, 200, 150))
    box.center()
    m = thorpy.Menu(box)
    m.play()

Ejemplo n.º 10
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)
Ejemplo n.º 11
0
        o.attach_to_player(player)
        scene.players.append(player)
        o.set_ia(100, 0.01)
    hero.reinit_orientation()
    hero.set_pos(parameters.HERO_POS)
    scene.put_hero_on_rail(0, 0)
    print("end main")
    scene.refresh_vessels()
    scene.hud.refresh_attributes()
    g = gamelogic.ShowRanking("Start list", "Go to race", scene.players)
    return scene, g.goback


if __name__ == "__main__":
    app = thorpy.Application((parameters.W, parameters.H))
    thorpy.set_theme(parameters.THEME)
    ##    thorpy.application.SHOW_FPS = True
    screen = thorpy.get_screen()
    import dialog

    def launch_about():
        dialog.launch_blocking_alert(
            "Credits",
            "Author: Yann Thorimbert\nLibraries used: Pygame, ThorPy (www.thorpy.org)",
            transp=False)
        e_bckgr.unblit_and_reblit()

    DEBUG = False

    def play():
        ##        if not DEBUG:
Ejemplo n.º 12
0
def set_theme(theme):
    thorpy.set_theme(theme)
    thorpy.style.DEF_COLOR = (150, 150, 150)