示例#1
0
def back():
    global gui
    if not gui is None:
        gui.stop()
    console.clear()

    run_menu()
示例#2
0
def run_map_editor():
    global gui
    gui.stop()
    del gui
    console.clear()

    from map_editor import run_editor
    run_editor()
示例#3
0
def play_map(map):
    if data.playerData.isLocked(map):
        return
    global gui
    if not gui == None:
        gui.stop()
    console.clear()

    from game import run_game
    run_game(map)
示例#4
0
def instructions():
    global gui
    if not gui == None:
        gui.stop()
    console.clear()

    banner = [
        " ", " ", "###", " #  #  # ### ### # ## # #  ##  ##   ##  ###",
        " #  ## # ##   #  ##   # # #   #  # #### ##",
        " #  # ##  ##  #  #    # # #   #  # #     ##",
        "### #  # ###  #  #    ###  ##  ##   ##  ###"
    ]
    for yBanner in range(0, len(banner)):
        for xBanner in range(0, len(banner[yBanner])):
            text = banner[yBanner][xBanner]

            if text == '#':
                console.setColorXY(
                    xBanner + int(SCREEN_COLUMNS / 6), yBanner, ' ',
                    Colors.BACKGROUND_YELLOW | Colors.BACKGROUND_BOLD)
    console.setColor(Colors.BACKGROUND_BLACK | Colors.FOREGROUND_WHITE)

    gui = GUI(len(banner) + 16, 0)

    gui.addButton(len(banner) + 5, 0, GUIButton('1', ["   Instruções:"]))
    gui.addButton(
        len(banner) + 7, 0, GUIButton('2', ["        W = Mover para cima"]))
    gui.addButton(
        len(banner) + 8, 0, GUIButton('3', ["        S = Mover para baixo"]))
    gui.addButton(
        len(banner) + 9, 0, GUIButton('4',
                                      ["        A = Mover para esquerda"]))
    gui.addButton(
        len(banner) + 10, 0, GUIButton('5',
                                       ["        D = Mover para direita"]))
    gui.addButton(
        len(banner) + 11, 0, GUIButton('6',
                                       ["        (ou, utilize as setas)"]))
    gui.addButton(
        len(banner) + 13, 0,
        GUIButton('7', [
            "    * Seu objetivo é encontrar a saída do labirinto (ponto VERDE)"
        ]))
    gui.addButton(
        len(banner) + 14, 0,
        GUIButton('8', [
            "      dentro do tempo limite, para assim, liberar a próxima fase!"
        ]))
    gui.addButton(
        len(banner) + 16, 0,
        GUIButton("Voltar", ["     < Voltar ao menu"], lambda: back(), None,
                  Colors.FOREGROUND_WHITE, Colors.FOREGROUND_BLACK,
                  Colors.BACKGROUND_RED, Colors.BACKGROUND_RED))

    gui.display()
def back_to(to):
	global gui
	gui.stop()
	del gui
	console.clear()

	if to == "menu":
		from menu import run_menu
		run_menu()
	elif to == "editor":
		run_editor()
	def cancel(gui):
		global CREATING_MAP_NAME
		global CREATING_MAP_HEIGHT
		global CREATING_MAP_WIDTH
		global CREATING_MAP_TIME
		global CREATING_MAP_AUTO_GENERATION
		global CREATING_MAP_THREAD

		CREATING_MAP_NAME = ""
		CREATING_MAP_HEIGHT = ""
		CREATING_MAP_WIDTH = ""
		CREATING_MAP_TIME = ""
		CREATING_MAP_AUTO_GENERATION = ""
		CREATING_MAP_THREAD = None

		console.clear()
		run_editor()
	def confirm(gui):
		global CREATING_MAP_NAME

		if not get_map_by_name(CREATING_MAP_NAME) is None:
			console.setColorXY(5, len(MAPS) + 20, " >> Já existe um mapa com esse nome...", Colors.BACKGROUND_RED | Colors.FOREGROUND_WHITE)
		else:
			global CREATING_MAP_HEIGHT
			global CREATING_MAP_WIDTH
			global CREATING_MAP_TIME
			global CREATING_MAP_AUTO_GENERATION

			if CREATING_MAP_HEIGHT == "" or CREATING_MAP_WIDTH == "" or CREATING_MAP_TIME == "" or CREATING_MAP_AUTO_GENERATION == "":
				console.setColorXY(5, len(MAPS) + 20, " >> Um dos campos não foi preenchido...", Colors.BACKGROUND_RED | Colors.FOREGROUND_WHITE)
			elif not CREATING_MAP_HEIGHT.isdigit() or not CREATING_MAP_WIDTH.isdigit() or not CREATING_MAP_TIME.isdigit():
				console.setColorXY(5, len(MAPS) + 20, " >> O valor do campo Altura, Largura ou o Tempo não é um número válido...", Colors.BACKGROUND_RED | Colors.FOREGROUND_WHITE)
			else:
				composition = {}

				if CREATING_MAP_AUTO_GENERATION == "SIM":
					composition = generate_composition(int(CREATING_MAP_HEIGHT), int(CREATING_MAP_WIDTH))
				else:
					for y in range(0, int(CREATING_MAP_HEIGHT)):
						composition[y] = {}
						for x in range(0, int(CREATING_MAP_WIDTH)):
							if y == 0 or y == int(CREATING_MAP_HEIGHT) - 1 or x == 0 or x == int(CREATING_MAP_WIDTH) - 1:
								composition[y][x] = WALL
							else:
								composition[y][x] = SPACE

				map = Map(CREATING_MAP_NAME, len(MAPS) + 1, int(CREATING_MAP_TIME), int(CREATING_MAP_HEIGHT), int(CREATING_MAP_WIDTH), composition)
				map.save()
				MAPS.append(map)
				console.setColorXY(5, len(MAPS) + 20, " >> Mapa criado com sucesso!", Colors.BACKGROUND_GREEN | Colors.FOREGROUND_WHITE)
		sleep(3)
		gui.stop()
		del gui

		console.clear()
		run_editor()
示例#8
0
def play():
    global gui
    if not gui == None:
        gui.stop()
    console.clear()

    banner = [
        " ", " ", " ###                                           ###",
        "#      ##  #    ##   ## #  ##  #  #  ### # #   #    ### ###  ##",
        " ###  #### #   #### #     #  # ## # #  # ##    ##  #  # ##  ####",
        "    # #    #   #    #   # #  # # ## #  # #     #   #  #  ## #",
        " ###   ##  ###  ##   ## #  ##  #  #  ### #     #    ### ###  ##"
    ]
    for yBanner in range(0, len(banner)):
        for xBanner in range(0, len(banner[yBanner])):
            text = banner[yBanner][xBanner]

            if text == '#':
                console.setColorXY(
                    xBanner + int(SCREEN_COLUMNS / 6), yBanner, ' ',
                    Colors.BACKGROUND_YELLOW | Colors.BACKGROUND_BOLD)
    console.setColor(Colors.BACKGROUND_BLACK | Colors.FOREGROUND_WHITE)

    data.load_data()
    map_editor.load_maps()

    gui = GUI(10, 0)

    for mapIndex in range(0, len(map_editor.MAPS)):
        map = map_editor.MAPS[mapIndex]

        if data.playerData.isLocked(map):
            gui.addButton(
                mapIndex + 10, 0,
                GUIButton(map.name,
                          ["     ?. ?????        Melhor tempo: --:--"],
                          partial(play_map, map),
                          colorBackSelected=Colors.BACKGROUND_RED,
                          colorForeSelected=Colors.FOREGROUND_WHITE))
        else:
            timeString = ""
            if data.playerData.times[str(map.level)] == -1:
                timeString = "--:--"
            else:
                seconds = map.timeCounter - data.playerData.times[str(
                    map.level)]
                minutes = 0
                while seconds >= 60:
                    seconds -= 60
                    minutes += 1

                timeString = str(minutes) + ":" + str(seconds)

            gui.addButton(
                mapIndex + 10, 0,
                GUIButton(map.name, [
                    "     " + str(mapIndex + 1) + ". " + map.name +
                    "        Melhor tempo: " + timeString
                ], partial(play_map, map)))

    gui.addButton(
        len(map_editor.MAPS) + 11, 0,
        GUIButton("Voltar", ["     < Voltar ao menu"], lambda: back(), None,
                  Colors.FOREGROUND_WHITE, Colors.FOREGROUND_BLACK,
                  Colors.BACKGROUND_RED, Colors.BACKGROUND_RED))
    gui.display()