示例#1
0
def main():
    with open('the_map.xml', 'r') as fin:
        xml_file = fin.read()

    success, game_map = the_map.obj_wrapper(xml_file)

    # build a dictionary that maps room names to room objects
    global rooms_by_name
    for room in game_map.building:
        room_name = room.attrs["room"]
        rooms_by_name[room_name] = room


    # initialize the starting room
    global player
    player = game_map.player[0]
    last_room = None
    current_room = game_map.building[0]
    while True:
        if current_room is not last_room:
            describe(current_room)

        last_room = current_room
        command = raw_input(">")
        verb, nouns = parse_command(command)
        current_room = run_command(current_room, verb, nouns)
示例#2
0
def main():
    global game_map
    global player_inventory
    games = os.listdir("saved_games")
    pygame.mixer.init()
    pygame.init()
    sound = pygame.mixer.Sound("Secret_of_Mana_Opening_Theme.wav")
    sound.play()
    if games:
        for i, file_name in enumerate(games):
            print str(i) + "\t" + file_name.split(".")[0]
        choice = raw_input("choose a game or type 'N' for a new game\n>")
        if choice not in ["N", "n", "new", "NEW"]:
            try:
                game_file = "saved_games\\" + games[int(choice)]
            except:
                print "you failed to type a number. HOW?!?"
                exit()
        else:
            game_file = "the_map.xml"
    else:
        game_file = "the_map.xml"

    with open(game_file, "r") as fin:
        xml_file = fin.read()

    success, game_map = the_map.obj_wrapper(xml_file)

    # build a dictionary that maps room names to room objects
    global rooms_by_name
    for room in game_map.building:
        room_name = room.attrs["room"]
        rooms_by_name[room_name] = room

    # initialize the starting room
    global player
    player = game_map.player[0]
    player_inventory = game_map.player[0].item[0].attrs["name"]
    # player_inventory = game_map.player[0].inventory[0]
    last_room = None
    starting_room = int(player.attrs["room"])
    current_room = game_map.building[starting_room]

    intro()
    overworld_music(room)
    while True:
        if current_room is not last_room:
            describe(current_room)
        last_room = current_room
        command = raw_input(">")
        verb, noun = parse_command(command)
        os.system("CLS")
        current_room = run_command(current_room, verb, noun)
示例#3
0
def main():
    global game_map
    games = os.listdir("saved_games")
    if games:
        for i, file_name in enumerate(games):
            print str(i) + "\t" + file_name.split(".")[0]
        choice = raw_input("choose a game or type 'N' for a new game\n>")
        if choice not in ["N", "n", "new", "NEW"]:
            try:
                game_file = "saved_games\\" + games[int(choice)]
            except:
                print "you failed to type a number. HOW?!?"
                exit()
        else:
            game_file = 'the_map.xml'
    else:
        game_file = 'the_map.xml'

    with open(game_file, 'r') as fin:
        xml_file = fin.read()

    success, game_map = the_map.obj_wrapper(xml_file)

    # build a dictionary that maps room names to room objects
    global rooms_by_name
    for room in game_map.building:
        room_name = room.attrs["room"]
        rooms_by_name[room_name] = room


    # initialize the starting room
    global player
    player = game_map.player[0]
    last_room = None
    starting_room = int(player.attrs["room"])
    current_room = game_map.building[starting_room]
    intro()
    while True:
        if current_room is not last_room:
            describe(current_room)
        last_room = current_room
        command = raw_input(">")
        verb, noun = parse_command(command)
        os.system('CLS')
        current_room = run_command(current_room, verb, noun)