Ejemplo n.º 1
0
    def __init__(self, gameState, screen):

        self.gameState = gameState
        self.font = pygame.font.SysFont("monospace", 15)
        self.screen = screen

        pokemon_button = thorpy.make_button("Pokemons",
                                            func=change_state_loop,
                                            params={"gui": self})
        quit_button = thorpy.make_button("Quit",
                                         func=change_state_loop,
                                         params={"gui": self})
        self.boxMap = thorpy.Box.make(elements=[pokemon_button, quit_button])
        self.menuMap = thorpy.Menu(self.boxMap)
        for element in self.menuMap.get_population():
            element.surface = screen
        self.boxMap.set_topleft((0, 502))

        attack_button = thorpy.make_button("Attack", func=self.attack_enemy)
        escape_button = thorpy.make_button("Escape", func=self.flee)
        self.boxBattle = thorpy.Box.make(
            elements=[attack_button, escape_button])
        self.menuBattle = thorpy.Menu(self.boxBattle)
        for element in self.menuBattle.get_population():
            element.surface = screen
        self.boxBattle.set_topleft((0, 502))
        pass
Ejemplo n.º 2
0
    def __init__(self, screen, scene_manager):
        super(State, self).__init__()
        self.scene_manager = scene_manager
        self.screen = screen
        self.screen_rect = self.screen.get_rect()
        # font settings
        self.font_size = 18
        self.font_name = pygame.font.match_font('arial')
        self.font = pygame.font.Font(self.font_name, self.font_size)
        # define colors
        self.WHITE = (255, 255, 255)
        self.BLACK = (0, 0, 0)
        self.RED = (255, 0, 0)
        self.GREEN = (0, 255, 0)
        self.BLUE = (0, 0, 255)
        self.YELLOW = (255, 255, 0)
        self.BAR_LENGTH = 100
        self.BAR_HEIGHT = 10
        # menu
        self.quit_btn = thorpy.make_button("Quit", func=thorpy.functions.quit_func)
        self.ng_btn = thorpy.make_button("New game", func = self.scene_manager.go_to, params = {'scene':'game', 'state':'init'})
        self.res_btn = thorpy.make_button("Resume", func = self.scene_manager.go_to, params = { 'scene':'game', 'state':'resume'})
        self.box = thorpy.Box.make(elements=[self.quit_btn, self.ng_btn, self.res_btn])

        self.menu = thorpy.Menu(self.box)
        for element in self.menu.get_population():
            element.surface = self.screen
        self.box.set_topleft((200, 200))
Ejemplo n.º 3
0
    def first_render(self, location):
        self.elements = []
        self.elements.append(thorpy.make_text("Smelter"))
        self.smelt_items = [thorpy.Clickable.make("None") for x in range(self.max_inv_size)]
        self.button = thorpy.make_button("Smelt", func=self.smelt)
        self.smelt_item_box = thorpy.Box.make(elements=self.smelt_items)
        self.elements.append(self.smelt_item_box)
        self.elements.append(self.button)

        self.smelted_item = thorpy.Clickable.make("None")
        self.smelted_item_box = thorpy.Box.make(elements=[self.smelted_item])
        self.elements.append(self.smelted_item_box)
        self.box = thorpy.Box.make(elements=self.elements)
        self.drag = thorpy.Draggable.make(elements=[self.box])

        reaction = thorpy.Reaction(reacts_to=thorpy.constants.THORPY_EVENT,
                            reac_func=self._pop_smelter,
                            params={"item": self.smelted_item},
                            event_args={"id":thorpy.constants.EVENT_PRESS})



        for item in self.elements:
            item.center(axis=(True, False), element=self.box)

        self.drag.add_reaction(reaction)
        self.drag.set_topleft(location)
        self.sub_menu = thorpy.Menu(self.drag)
        thorpy.functions.set_current_menu(self.sub_menu)
        self.sub_menu.blit_and_update()
Ejemplo n.º 4
0
    def __init__(self, **args):
        """
			crea los campos de inserción, el botón y el menú que los agrupa
		"""
        self._inserters = OrderedDict()
        self._boton = None
        self._valores = OrderedDict()
        self._superficie = None
        self._menu = thorpy.Menu()
        self._caja = None
        self._activado = False

        if 'entradas' in args:
            for entrada in args['entradas']:
                self._inserters[entrada] = thorpy.Inserter(entrada + ": ")
                self._valores[entrada] = None

            self._boton = thorpy.make_button('Aceptar', func=self.leer)
            elementos = [v for v in self._inserters.values()]
            elementos.append(self._boton)
            self._caja = thorpy.Box(elements=elementos)
            self._boton.set_topleft((50, 50))
            #self._caja.add_elements([self._boton])
            self._caja.blit()
            self._caja.update()
            self._menu.add_to_population(self._caja)

        if 'func' in args:
            # no aplica para este programa, porque llama a la función de lanzar
            pass
Ejemplo n.º 5
0
 def __init__(self, parent, screen, background, font):
     super().__init__(parent, screen, background, font)
     self.rows = 15
     self.columns = 15
     self.mine_count = (self.rows * self.columns) / 10
     self.gameboard = Minefield(self, screen, background, font, self.rows,
                                self.columns, self.mine_count)
     self.title = thorpy.make_text('Minesweeper',
                                   font_size=20,
                                   font_color=(0, 0, 150))
     self.start_button = thorpy.make_button(
         'New Game',
         func=MainMenu.activate_gameboard,
         params={'self': self})
     self.options_button = thorpy.make_button(
         'Options', func=MainMenu.activate_options, params={'self': self})
     self.quit_button = thorpy.make_button('Quit',
                                           func=MainMenu.quit,
                                           params={'self': self})
     self.box = thorpy.Box(elements=[
         self.title, self.start_button, self.options_button,
         self.quit_button
     ],
                           size=(screen.get_width(), screen.get_height()))
     thorpy.store(self.box)
     self.menu = thorpy.Menu(self.box)
     for element in self.menu.get_population():
         element.surface = self.screen
Ejemplo n.º 6
0
 def set_up(self):
     self.info_box = thorpy.Box(self.elements)
     self.menu = thorpy.Menu(self.info_box)
     #Can't start the network stuff until all the gui elements are created
     self.make_save_score_thread() #start saving score in a separate thread
     self.render()
     self.start()
Ejemplo n.º 7
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()
Ejemplo n.º 8
0
def read_treasure(treas):
    title = thorpy.make_text(treas.title,
                             font_size=thorpy.style.FONT_SIZE + 3,
                             font_color=TCOLOR)
    line = thorpy.Line.make(100, "h")
    text = thorpy.make_text(thorpy.pack_text(100, treas.text))
    elements = [title, line, text]

    class Choice:
        ok = False

    def func_cancel():
        Choice.ok = True
        thorpy.functions.quit_menu_func()

    box = thorpy.make_ok_cancel_box(elements, "No, let it there",
                                    "Yes, take it")
    box.e_ok.user_func = thorpy.functions.quit_menu_func
    box.e_ok.user_params = {}
    box.e_cancel.user_func = func_cancel
    box.e_cancel.user_params = {}
    box.center()
    ##    box.add_reaction(thorpy.ConstantReaction(pygame.KEYDOWN,
    ##                                             thorpy.functions.quit_menu_func,
    ##                                             {"key":pygame.K_SPACE}))
    m = thorpy.Menu([box])
    m.play()
    return Choice.ok
Ejemplo n.º 9
0
    def first_render(self, location):
        self.elements = []
        self.elements.append(thorpy.make_text("Inventory"))
        self.item_clickables = [thorpy.Clickable.make("None") for x in range(self.max_inv_size)]
        self.item_box = thorpy.Box.make(elements=self.item_clickables)
        self.elements.append(self.item_box)
        self.button = thorpy.make_button("Inv", func=self._print_all)
        self.elements.append(self.button)
        self.inv_box = thorpy.Box.make(elements=self.elements)
        self.inv_drag = thorpy.Draggable.make(elements=[self.inv_box])


        for item in self.item_clickables:
            item.center(axis=(True, False), element=self.inv_box)
            
            # this reaction allows us to click the item we want to smelt
            # and transfer it into the smelter
            reaction = thorpy.Reaction(reacts_to=thorpy.constants.THORPY_EVENT,
                            reac_func=self._add_to_smelter,
                            params={"item": item},
                            event_args={"id":thorpy.constants.EVENT_PRESS})
            self.inv_drag.add_reaction(reaction)

        self.inv_drag.set_topleft(location)
        self.inv_menu = thorpy.Menu(self.inv_drag)
        thorpy.functions.set_current_menu(self.inv_menu)
        self.inv_menu.blit_and_update()
Ejemplo n.º 10
0
def init_ui(screen):
    slider = thorpy.SliderX(100, (5, 15), "Simulation speed")
    slider.user_func = slider_reaction
    button_stop = thorpy.make_button("Quit", func=stop_execution)
    button_pause = thorpy.make_button("Pause", func=pause_execution)
    button_play = thorpy.make_button("Play", func=start_execution)
    timer = thorpy.OneLineText("Seconds passed")

    button_load = thorpy.make_button(text="Load a file", func=open_file)

    box = thorpy.Box(elements=[
        slider, button_pause, button_stop, button_play, button_load, timer
    ])
    reaction1 = thorpy.Reaction(
        reacts_to=thorpy.constants.THORPY_EVENT,
        reac_func=slider_reaction,
        event_args={"id": thorpy.constants.EVENT_SLIDE},
        params={},
        reac_name="slider reaction")
    box.add_reaction(reaction1)

    menu = thorpy.Menu(box)
    for element in menu.get_population():
        element.surface = screen

    box.set_topleft((0, 0))
    box.blit()
    box.update()
    return menu, box, timer
Ejemplo n.º 11
0
def main():
    pygame.init()  # Iniciamos pygame.
    infoObject = pygame.display.Info()
    icon = pygame.image.load('images/ant.png')

    preferredSize = int(infoObject.current_h *
                        0.88)  # Obtenemos la altura de la pantalla.
    application = thorpy.Application((preferredSize, preferredSize),
                                     "Langton's Ant", "pygame")

    # Verifica si el tamaño ingresado es válido y si lo es, inicia la simulación.
    def start():
        if tamaño.get_value().isdigit() and iteraciones.get_value().isdigit():
            tam = int(tamaño.get_value())
            it = int(iteraciones.get_value())
            if tam > 0 and it > 0:
                if tam > int(0.65 * (preferredSize // 2)):
                    thorpy.launch_blocking_alert(
                        title="¡Tamaño no soportado!",
                        text=
                        "El tamaño actual generaría una grilla con celdas de tamaño cero.",
                        parent=background)
                    tamaño.set_value("")
                else:
                    simulation.simulate(tam, it, preferredSize)
            else:
                thorpy.launch_blocking_alert(title="¡Tamaño no soportado!",
                                             text="El tamaño no es válido.",
                                             parent=background)
        else:
            thorpy.launch_blocking_alert(
                title="¡Valores incorrectos!",
                text="Los valores introducidos no son válidos.",
                parent=background)
            tamaño.set_value("")
            iteraciones.set_value("")

    iteraciones = thorpy.Inserter(name="Iteraciones: ",
                                  value="1")  # Campo de número de iteraciones.
    tamaño = thorpy.Inserter(name="Tamaño: ", value="10")  # Campo de tamaño.
    boton = thorpy.make_button("Aceptar", start)  # Botón aceptar.

    title_element = thorpy.make_text("Configurar simulación", 22,
                                     (255, 255, 255))

    central_box = thorpy.Box(elements=[iteraciones, tamaño,
                                       boton])  # Contenedor central.
    central_box.fit_children(margins=(30, 30))
    central_box.center()  # center on screen
    central_box.set_main_color((220, 220, 220, 180))

    background = thorpy.Background((0, 0, 0),
                                   elements=[title_element, central_box])
    thorpy.store(background)

    menu = thorpy.Menu(background)
    menu.play()  # Lanzamos el menú.

    application.quit()
Ejemplo n.º 12
0
def launch(e, func=None):
    if not isinstance(e, thorpy.Ghost):#dirty hack because I'm lazy
        e = e.instructions
    print("launching",e)
    m = thorpy.Menu(e)
    m.play()
    if func:
        func()
Ejemplo n.º 13
0
    def displayLauncher():

        # Declare Variables
        index = None  #int
        game = None  #String
        application = None  #Application(thorpy)
        buttons = [None, None, None]  #Clickable(thorpy) Array
        scoreboardButton = None  #Clickable(thorpy)
        quitButton = None  #Clickable(thorpy)
        buttonGroup = None  #Group(thorpy)
        menu = None  #Menu(thorpy)
        background = None  #Background(thorpy)
        painter = None  #Painters(thorpy)
        title = None  #Text(thorpy)

        # Create GUI and set theme
        application = thorpy.Application(size=(1280, 800),
                                         caption="Mini-Arcade")
        thorpy.theme.set_theme("human")

        # Create title
        title = thorpy.make_text("Mini-Arcade\n", 35, (0, 0, 0))

        # Create buttons
        painter = thorpy.painters.roundrect.RoundRect(size=(150, 75),
                                                      color=(102, 204, 255),
                                                      radius=0.3)
        for index, game in enumerate(Launcher.gameTitle):
            buttons[index] = Launcher.createButton(game, index, painter)
        scoreboardButton = thorpy.Clickable("Scoreboard")
        scoreboardButton.user_func = Launcher.launchScoreboard
        scoreboardButton.set_painter(painter)
        scoreboardButton.finish()
        scoreboardButton.set_font_size(23)
        scoreboardButton.set_font_color_hover((255, 255, 255))
        quitButton = thorpy.Clickable("Exit")
        quitButton.user_func = thorpy.functions.quit_menu_func
        quitButton.set_painter(painter)
        quitButton.finish()
        quitButton.set_font_size(23)
        quitButton.set_font_color_hover((255, 255, 255))

        # Format the buttons
        buttonGroup = thorpy.make_group(buttons)

        # Set background
        background = thorpy.Background(
            color=(255, 255, 255),
            elements=[title, buttonGroup, scoreboardButton, quitButton])
        thorpy.store(background)

        # Create menu and display
        menu = thorpy.Menu(background)
        menu.play()

        # Exiting
        application.quit()
Ejemplo n.º 14
0
def main_menu(width, height, func_run, func_menu):
    def func_about():
        about_text = thorpy.make_text(
            'Game of the Hyenas \n '
            'by \n\n '
            'AnDreWerDnA'
            ' \n 700y \n Pk \n\n '
            '-  Python Code Jam 5 -', 25)

        normal_about, hover_about = 'assets/back-on.png',\
                                    'assets/back-off.png',

        back_button = thorpy.make_image_button(img_normal=normal_about,
                                               img_hover=hover_about,
                                               colorkey=(0, 0, 0))
        back_button.user_func = func_menu
        about_background = thorpy.Background(
            image='map_objects/menu_bg.jpg',
            elements=[about_text, back_button])
        thorpy.store(about_background)
        about_menu = thorpy.Menu(about_background)
        about_menu.play()

    application = thorpy.Application((width, height),
                                     "Code Jam",
                                     icon='pyGame')

    normal, hover = 'assets/play-on.png', 'assets/play-off.png'
    normal_quit, hover_quit = 'assets/quit-on.png', 'assets/quit-off.png'
    normal_about, hover_about = 'assets/about-on.png', 'assets/about-off.png'

    play_button = thorpy.make_image_button(img_normal=normal,
                                           img_hover=hover,
                                           colorkey=(0, 0, 0))

    about_button = thorpy.make_image_button(img_normal=normal_about,
                                            img_hover=hover_about,
                                            colorkey=(0, 0, 0))

    quit_button = thorpy.make_image_button(img_normal=normal_quit,
                                           img_hover=hover_quit,
                                           colorkey=(0, 0, 0))

    background = thorpy.Background(
        image='map_objects/menu_bg.jpg',
        elements=[play_button, about_button, quit_button])
    # Set functions for the buttons
    play_button.user_func = func_run
    quit_button.set_as_exiter()
    about_button.user_func = func_about
    thorpy.store(background)
    menu = thorpy.Menu(background)
    menu.play()

    application.quit()
Ejemplo n.º 15
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()
Ejemplo n.º 16
0
 def startQuizGameBG(self):
     if self.timeLeft == 0:
         self.rt.stop()
     self.timeLeft -= 0.125
     self.quizGame = thorpy.Background(image='quizAbstract.jpg',
                                       elements=[
                                           self.questionText,
                                           self.Op1Button, self.Op2Button,
                                           self.Op3Button, self.Op3Button,
                                           self.Op4Button, self.quit3
                                       ])
     self.quizGamePage = thorpy.Menu(self.quizGame)
     self.quizGamePage.play()
Ejemplo n.º 17
0
 def create_instructions(self):
     self.ins_buttons = [
         thorpy.make_button(txt, func=self.ins_func[txt])
         for txt in self.ins_func.keys()
     ]
     [button.set_font_size(30) for button in self.ins_buttons]
     [button.scale_to_title() for button in self.ins_buttons]
     self.ins_box = thorpy.Box(self.ins_buttons)
     self.ins_box.set_main_color((0, 0, 0, 0))
     thorpy.store(self.ins_box, mode="h", gap=40)
     self.ins_box.set_topleft((170, 540))
     self.ins_box.fit_children()
     return thorpy.Menu(self.ins_box)
Ejemplo n.º 18
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.º 19
0
 def create(self):
     self.state.append("main_menu")
     self.fill_buttons_list()
     self.fill_text_list()
     self.fill_inserters()
     self.background = thorpy.Background(
         color=None,
         image="backgrounds/login_background.png",
         elements=self.buttons + self.texts + self.inserters)
     self.place_elements_on_background()
     self.menu = thorpy.Menu(self.background)
     for element in self.menu.get_population():
         element.surface = self.window
     self.update_background()
     return self.menu
Ejemplo n.º 20
0
    def create_menu(self, screen_size):
        ##        print(screen_size, screen_size[0] - 2*self.abs_off[0])
        # Colocamos el Slider
        self.slider = thorpy.SliderX.make(
            screen_size[0] - 2 * self.abs_off[0] - 130, self.rank, self.name)
        ##        self.button = thorpy.make_button("Quit", func=thorpy.functions.quit_func)

        self.box = thorpy.Box.make(elements=[self.slider])
        self.menu = thorpy.Menu(self.box)

        for element in self.menu.get_population():
            element.surface = self.parent.screen

        self.set_slider_value(100.0)
        return None
Ejemplo n.º 21
0
 def init_thorpy(self):
     res_trees = thorpy.OneLineText("Trees: " + str(
         len(
             self.ai_player.entities_where(
                 lambda e: isinstance(e, entities.Tree)))))
     self.box = thorpy.Box(elements=[res_trees])
     self.box_u = thorpy.Box(elements=[res_trees])
     self.box_r = thorpy.Box(elements=[res_trees])
     #we regroup all elements on a menu, even if we do not launch the menu
     menu = thorpy.Menu([self.box, self.box_u])
     #important : set the screen as surface for all elements
     for element in menu.get_population():
         element.surface = self.screen
     #use the elements normally...
     self.box.set_topleft((0, 0))
Ejemplo n.º 22
0
def main():
    pygame.init()
    screen = display.set_mode((WIDTH, HEIGHT), 0, 32)

    # declaration of algorithms for ThorPy buttons
    runKnn = thorpy.make_button("kNN", func=lambda: run_classification("KNN"))
    runLda = thorpy.make_button("LDA", func=lambda: run_classification("LDA"))
    runNB = thorpy.make_button("NB", func=lambda: run_classification("NB"))
    runTree = thorpy.make_button("Decision Tree",
                                 func=lambda: run_classification("TREE"))
    runForest = thorpy.make_button("Random Forest",
                                   func=lambda: run_classification("RF"))
    runSvc = thorpy.make_button("SVM", func=lambda: run_classification("SVM"))
    runGB = thorpy.make_button("Gradient Boosting",
                               func=lambda: run_classification("GB"))
    runPerc = thorpy.make_button("Perceptron",
                                 func=lambda: run_classification("PERC"))
    runReset = thorpy.make_button("RESET", func=reset)
    # create a box of buttons
    box = thorpy.Box.make(elements=[
        runKnn, runLda, runNB, runTree, runForest, runSvc, runGB, runPerc,
        runReset
    ])
    menu = thorpy.Menu(box)
    box.set_topleft((600, 5))
    box.blit()
    box.update()

    display.set_caption("Classification algorithms tester byPK")

    while True:
        clock.tick(40)
        for event in pygame.event.get():
            menu.react(event)  #read an event
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            if pygame.mouse.get_pressed()[0]:
                pos = pygame.mouse.get_pos()
                if pos[0] < 600:
                    if color == RED:
                        red_points.append(pos)
                    if color == GREEN:
                        green_points.append(pos)
                if pos[0] > 600 and pos[1] > 450:  #click on switch area
                    switch_color()
            refresh(screen)
        display.update()
Ejemplo n.º 23
0
def get_journal(game):
    journal_title = thorpy.make_text("Journal",
                                     font_size=thorpy.style.FONT_SIZE + 3,
                                     font_color=TCOLOR)
    line = thorpy.Line.make(100, "h")
    elements = []
    #entries
    for name, day, coord, h, t, text in game.journal.entries:
        e_name = thorpy.make_text(name, font_color=(0, 0, 255))
        infos = thorpy.make_text(" ".join([
            "| Day",
            str(day), ", coord=", coord, ", alt=",
            str(round(h)), ", temp=",
            str(round(t))
        ]),
                                 font_color=(50, 50, 150))
        ##            e_title = thorpy.Element.make(elements=[e_name,infos])
        ##            thorpy.store(e_title, mode="h")
        e_title = thorpy.make_group([e_name, infos])
        e_title.fit_children()
        elements.append(e_title)
        elements.append(thorpy.make_text("    " + thorpy.pack_text(400, text)))
    subbox = thorpy.Element.make(elements=elements, size=(500, 300))
    thorpy.store(subbox, elements, x=3, y=0, align="left", gap=3)

    #
    def add_entry():
        add_journal_entry(game)
        thorpy.functions.quit_menu_func()

    ok = thorpy.make_button("Ok", func=thorpy.functions.quit_menu_func)
    add = thorpy.make_button("Add entry", func=add_entry)
    ok_add = thorpy.make_group([ok, add])
    #
    box = thorpy.Element.make(elements=[journal_title, subbox, ok_add])
    box.set_main_color((200, 200, 200, 100))
    thorpy.store(box)
    box.fit_children()
    box.set_size((None, int(1.3 * subbox.get_fus_rect().h)))
    #
    subbox.set_prison()
    subbox.refresh_lift()
    ##    box.add_reaction(thorpy.ConstantReaction(pygame.KEYDOWN,
    ##                                             thorpy.functions.quit_menu_func,
    ##                                             {"key":pygame.K_SPACE}))
    box.center()
    m = thorpy.Menu([box])
    m.play()
Ejemplo n.º 24
0
def Menu():
    '''Создает окно запуска'''
    button_play = thorpy.make_button("Play",start_execution)
    timer = thorpy.OneLineText("Seconds passed")
    box = thorpy.Box(elements=[
        button_play,
        timer])
    my_reaction = thorpy.Reaction(reacts_to=thorpy.constants.THORPY_EVENT,
                                  reac_func=start_execution)
    menu = thorpy.Menu(box)
    for element in menu.get_population():
        element.surface = screen

    box.set_topleft((0, 0))
    box.blit()
    box.update()
    return menu,box,timer
Ejemplo n.º 25
0
 def draw_gui(self):
     resources = self.grid.resources
     self.checkers = [
         thorpy.Checker.make(resource.name, value=False)
         for resource in resources
     ]
     button = thorpy.make_button("Combine", func=self.combine)
     elements = []
     elements += self.checkers
     elements.append(button)
     box = thorpy.Box.make(elements=elements)
     self.menu = thorpy.Menu(box)
     for element in self.menu.get_population():
         element.surface = self.screen
     box.set_topleft((100, 100))
     box.blit()
     box.update()
Ejemplo n.º 26
0
def launch_menu(choices):
    title = thorpy.make_text("Выбери уровень", 14, (0, 0, 0))

    def at_press(what):
        global picked_level
        picked_level = what
        thorpy.functions.quit_menu_func()

    elements = []
    for text in choices:
        element1 = thorpy.make_button(text, func=at_press)
        element1.user_params = {"what": text}
        elements.append(element1)
    box1 = thorpy.Box([title] + elements)
    box1.set_main_color((200, 200, 200, 150))
    box1.center()
    m = thorpy.Menu(box1)
    m.play()
Ejemplo n.º 27
0
 def __init__(self, parent, screen, background, font, rows, columns):
     super().__init__(parent, screen, background, font)
     self.quit_button = thorpy.make_button('Return',
                                           func=OptionMenu.quit,
                                           params={'self': self})
     self.varset = thorpy.VarSet()
     self.varset.add('rows', value=rows, text='Rows:', limits=(5, 20))
     self.varset.add('columns',
                     value=columns,
                     text='Columns:',
                     limits=(5, 20))
     self.box = thorpy.ParamSetter([self.varset],
                                   elements=[self.quit_button],
                                   size=(screen.get_width(),
                                         screen.get_height()))
     thorpy.store(self.box)
     self.menu = thorpy.Menu(self.box)
     for element in self.menu.get_population():
         element.surface = self.screen
Ejemplo n.º 28
0
 def create(self, which_map):
     self.fill_elements_table()
     self.fill_radio_buttons()
     self.fill_icons_table()
     buttons = self.make_buttons()
     self.radio_pool = thorpy.RadioPool(self.radio_buttons,
                                        first_value=self.radio_buttons[0],
                                        always_value=True)
     self.background = thorpy.Background(
         color=(168, 139, 50),
         image=backgrounds[str(which_map)],
         elements=self.elements + self.radio_buttons + buttons + self.icons)
     self.menu = thorpy.Menu(self.background)
     for element in self.menu.get_population():
         element.surface = self.window
     self.place_elements(buttons)
     self.buttons_appearing(0)
     self.background.blit()
     self.background.update()
Ejemplo n.º 29
0
    def quiz_resultsLoader(self):
        print("Reached Here - Quiz page")
        self.createQuizElements()
        #self.rt = RepeatedTimer(0.1246, self.startQuizGameBG) #Initiate a 1-second non-blocking timer
        self.startQuizGameBG()

        global correct
        print("Reached Here - Results page")
        print(correct)
        if correct == True:
            self.resultText = thorpy.make_text("Correct! Fantastic!", 60,
                                               (0, 0, 0, 160))
        else:
            self.resultText = thorpy.make_text(
                "Good try! \nYou might get it right next time.", 60,
                (0, 0, 0, 160))
            self.correctAns.center()
            self.correctAns.set_topleft((None, 235))
        self.resultText.center()
        self.resultText.set_topleft((None, 30))
        #self.resultsBG = thorpy.Background(image='abstract.jpg', elements=[self.resultText, self.nextQuestion, self.OKbutton1, self.correctAns, self.quit4])

        #self.resultsBG = thorpy.Background(image='abstract.jpg', elements=[self.resultText, self.nextQuestion, self.OKbutton1, self.correctAns, self.quit4])
        if correct == True:
            print("I'm supposed to be here...")
            self.resultsBG = thorpy.Background(image='abstract.jpg',
                                               elements=[
                                                   self.resultText,
                                                   self.nextQuestion,
                                                   self.OKbutton1, self.quit4
                                               ])
            correct = False
        else:
            self.resultsBG = thorpy.Background(image='abstract.jpg',
                                               elements=[
                                                   self.resultText,
                                                   self.nextQuestion,
                                                   self.OKbutton1,
                                                   self.correctAns, self.quit4
                                               ])
        self.resultsPage = thorpy.Menu(self.resultsBG)
        self.resultsPage.play()
Ejemplo n.º 30
0
    def __init__(self, screen) -> None:
        self.game_id = None
        self.screen = screen
        
        self.startNewButton = thorpy.make_button("Start Game", func=self.add_players)
        self.joinButton = thorpy.make_button("Join Game", func=self.join_game)

        self.player1Edit = thorpy.Inserter.make("Player 1 name: ")
        self.player2Edit = thorpy.Inserter.make("Player 2 name: ")

        self.box = thorpy.Box.make(elements=[self.startNewButton, self.joinButton], size=(300, 300))
        thorpy.store(self.box)
        self.box.set_center((screen_middle_h, screen_middle_v))

        self.menu = thorpy.Menu(self.box)
        for el in self.menu.get_population():
            el.surface = self.screen

        self.box.blit()
        self.box.update()