示例#1
0
# You can have more than one way of using a connection by combining them in a list.
# In Python, [] brackets make a list.
# example: new_connection = Connection("The Connection Name", location_a, location_b, [direction_a, other_direction_a], [direction_b, other_direction_b])
big_door = Connection("Big Door", sidewalk, vestibule, [IN, WEST], [OUT, EAST])
# You can omit the 2nd direction and it will just be the opposite of the 1st
stairs = Connection("Stairs", vestibule, reception, UP)
steps_to_reception = Connection("A Few Steps", reception, intersection, NORTH)

# Now add the connections to the game too.
game.add_connection(big_door)
game.add_connection(stairs)
game.add_connection(steps_to_reception)

# You can also create and add a connection with a single convenience function that allows
# you to omit the name of the connection.  This is the preferred way to add connections:
game.connect(intersection, elevator, EAST)

# Create some objects to put in your game. You need a name and
# a description for the object you are making.
# example: something = Object("Object Name", "A description for the object")
# If you add True as the last argument, then it's an item that can't be taken.
elev_key = Object("key", "small tarnished brass key")

sidewalk.add_object(elev_key)

pebble = sidewalk.add_object(Object("pebble", "round pebble"))
sidewalk.add_object(
    Object("Gary the garden gnome",
           "a small figure liberated from a nearby garden."))

# You can make rooms require things, like keys, before a player can enter them.
示例#2
0
blood_extractor = BloodExtractor(
    "BE50K", "An infernally-looking machine that extracts blood",
    Say("This looks rather funny...?"), hero)
icommunicator_messages = Object(
    "LocationMessage",
    "'Did you know you could change your cruise-ship for just 10 more years of volunteering?"
    " Maybe Vromarion is not your thing? Trobatron Megacruises might just be the thing for you'",
    fixed=True)

personal_blood_room.add_object(icommunicator_messages)
hero.set_location(lobby)

personal_blood_room.add_object(blood_extractor)

game.connect(lobby, blood_room, RIGHT)
game.connect(blood_room, personal_blood_room, IN)

# def update():
#   game.entering_location(lobby)

# # and let's add a test to check the code we wrote above:
test_script = Script(
    "test", """
> go right
> go in
> look at LocationMessage
> eat happypills50K
> use BE50K
> use BE50K
> end
示例#3
0
# You can have more than one way of using a connection by combining them in a list.
# In Python, [] brackets make a list.
# example: new_connection = Connection("The Connection Name", location_a, location_b, [direction_a, other_direction_a], [direction_b, other_direction_b])
big_door = Connection("Big Door", sidewalk, vestibule, [IN, WEST], [OUT, EAST])
# You can omit the 2nd direction and it will just be the opposite of the 1st
stairs = Connection("Stairs", vestibule, reception, UP)
steps_to_reception = Connection("A Few Steps", reception, intersection, NORTH)

# Now add the connections to the game too.
game.add_connection(big_door)
game.add_connection(stairs)
game.add_connection(steps_to_reception)

# You can also create and add a connection with a single convenience function that allows
# you to omit the name of the connection.  This is the preferred way to add connections:
game.connect(intersection, elevator, EAST)

# Create some objects to put in your game. You need a name and
# a description for the object you are making.
# example: something = Object("Object Name", "A description for the object")
# If you add True as the last argument, then it's an item that can't be taken.
elev_key = Object("key", "small tarnished brass key")

sidewalk.add_object(elev_key)

pebble = sidewalk.add_object(Object("pebble", "round pebble"))
sidewalk.add_object(Object("Gary the garden gnome",
  "a small figure liberated from a nearby garden."))


# You can make rooms require things, like keys, before a player can enter them.
示例#4
0
                       "happypills50K: A pill a day takes the boredom away",
                       Say("Happy pills make me happy!"))

blood_extractor = BloodExtractor("BE50K", "An infernally-looking machine that extracts blood", Say("This looks rather funny...?"), hero)
icommunicator_messages = Object("LocationMessage", "'Did you know you could change your cruise-ship for just 10 more years of volunteering?"
                                                   " Maybe Vromarion is not your thing? Trobatron Megacruises might just be the thing for you'", fixed = True)

personal_blood_room.add_object(icommunicator_messages)
hero.set_location(lobby)



personal_blood_room.add_object(blood_extractor)


game.connect(lobby,blood_room, RIGHT)
game.connect(blood_room,personal_blood_room, IN)



# def update():
#   game.entering_location(lobby)


# # and let's add a test to check the code we wrote above:
test_script = Script("test",
"""
> go right
> go in
> look at LocationMessage
> eat happypills50K