本文整理汇总了Python中world.tile_exists函数的典型用法代码示例。如果您正苦于以下问题:Python tile_exists函数的具体用法?Python tile_exists怎么用?Python tile_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tile_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: play
def play():
world.load_tiles()
# pcs = npcs()
player = Player()
room = world.tile_exists(player.location_x, player.location_y)
# print(room.tile_name())
# print vars(room)
print room.room_name()
print room.intro_text()
while player.is_alive() and not player.victory:
room = world.tile_exists(player.location_x, player.location_y)
room.modify_player(player)
# Check again since the room could have changed the player's state
if player.is_alive() and not player.victory:
# print("Choose an action:\n")
available_actions = room.available_actions()
room.exits_text()
# print exits
# for action in available_actions:
# print(action)
# print " "
action_input = raw_input('\tWhat would you like to do? :')
action_input = parse_translate(action_input)
# print action_input
action_parser(action_input, available_actions, player, room)
示例2: play
def play():
world.load_tiles()
player = Player()
room = world.tile_exists(player.location_x, player.location_y)
# print(room.tile_name())
# print vars(room)
print room.room_name()
print room.intro_text()
while player.is_alive() and not player.victory:
room = world.tile_exists(player.location_x, player.location_y)
room.modify_player(player)
# Check again since the room could have changed the player's state
if player.is_alive() and not player.victory:
# print("Choose an action:\n")
available_actions = room.available_actions()
room.exits_text()
# print exits
for action in available_actions:
print (action)
# print " "
action_input = raw_input("\tWhat would you like to do? :")
for action in available_actions:
if action_input == action.hotkey:
player.do_action(action, **action.kwargs)
break
示例3: get_dir
def get_dir(self):
x = 0
y = 0
if self.x < self.dest_x and world.tile_exists(self.x + 1, self.y):
#print "xdir is east"
xdir = 'east'
x = 1
elif self.x > self.dest_x and world.tile_exists(self.x - 1, self.y):
xdir = 'west'
x = -1
#print "xdir is west"
else:
xdir = None
x = 0
#print "xdir is None"
if self.y > self.dest_y and world.tile_exists(self.x, self.y -1):
ydir = "north"
y = -1
#print "ydir is north"
elif self.y < self.dest_y and world.tile_exists(self.x, self.y +1):
#print "ydir is south"
ydir = "south"
y = 1
else:
ydir = None
#print "ydir is None"
y = 0
return x, xdir, y, ydir
示例4: play
def play():
world.load_tiles()
# pcs = npcs()
global player
global room
player = Player()
room = world.tile_exists(player.location_x, player.location_y)
# print vars(room)
print room.room_name()
print room.intro_text()
if room.inventory is not None:
for item in room.inventory:
print "\t{} is here.".format(item.name)
room.exits_text()
while player.is_alive() and not player.victory:
room = world.tile_exists(player.location_x, player.location_y)
room.modify_player(player)
# Check again since the room could have changed the player's state
if player.is_alive() and not player.victory:
# print("Choose an action:\n")
global available_actions
available_actions = room.available_actions()
Prompt().cmdloop()
示例5: play
def play():
"""
Loop del juego
"""
print("\n====================================================================")
world.create_world()
player = Player()
room = world.tile_exists(player.location_x, player.location_y)
print(room.intro_text())
while player.is_alive() and not player.victory:
room = world.tile_exists(player.location_x, player.location_y)
room.modify_player(player)
if player.is_alive() and not player.victory:
print("\nElegí una acción:\n")
available_actions = room.available_actions()
for action in available_actions:
print(action)
action_input = input("\nAcción: ")
print("====================================================================")
for action in available_actions:
if action_input == action.hotkey:
player.do_action(action, **action.kwargs)
if action_input == 'i':
print(room.intro_text())
break
if not player.is_alive():
print("PERDISTE!\nIgual no te preocupes, la princesa estaba en otro castillo")
elif player.victory:
print("Lo siento, la princesa esta en otro castillo!")
示例6: play
def play():
world.load_tiles()
player = Player()
room = world.tile_exists(player.location_x, player.location_y)
print(room.intro_text())
while player.is_alive() and not player.victory:
room = world.tile_exists(player.location_x, player.location_y)
room.modify_player(player)
if room.id == CONST.EXIT_TILE_ID:
player.victory = True
if player.is_alive() and not player.victory:
print("Choose an action:\n")
available_actions = room.available_actions()
for action in available_actions:
print(action)
action_input = input('Action: ')
for action in available_actions:
if action_input == action.hotkey:
player.do_action(action, **action.kwargs)
break
示例7: play
def play():
world.load_tiles()
player = Player()
room = world.tile_exists(player.location_x, player.location_y)
print(room.intro_text())
while player.is_alive() and not player.victory:
room = world.tile_exists(player.location_x, player.location_y)
room.modify_player(player)
# Check again since the room could have changed the player's state
if player.is_alive() and not player.victory:
if player.hp < player.maxhp:
player.hp += 1
print("Choose an action:\n")
available_actions = room.available_actions()
for action in available_actions:
print(action)
action_input = input('Action: ')
print()
for action in available_actions:
if action_input == action.hotkey:
player.do_action(action, **action.kwargs)
break
if not player.is_alive():
print('You are dead.')
示例8: move
def move(self, dx, dy):
"""Move the player in the direction x and y.
:param dx: The x-coordinate direction to move the player.
:param dy: The y-coordinate direction to move the player.
"""
self.location_x += dx
self.location_y += dy
world.tile_exists(self.location_x, self.location_y).intro_text()
示例9: adjacent_moves
def adjacent_moves(self):
""" Devuelve todas las direcciones en las que el jugador puede moverse."""
moves = []
if world.tile_exists(self.x + 1, self.y):
moves.append(actions.MoveEast())
if world.tile_exists(self.x - 1, self.y):
moves.append(actions.MoveWest())
if world.tile_exists(self.x, self.y - 1):
moves.append(actions.MoveNorth())
if world.tile_exists(self.x, self.y + 1):
moves.append(actions.MoveSouth())
return moves
示例10: adjacent_moves
def adjacent_moves(self):
"""Returns all move actions for adjacent tiles"""
moves = []
if world.tile_exists(self.x + 1, self.y):
moves.append(actions.MoveEast())
if world.tile_exists(self.x - 1, self.y):
moves.append(actions.MoveWest())
if world.tile_exists(self.x, self.y - 1):
moves.append(actions.MoveNorth())
if world.tile_exists(self.x, self.y + 1):
moves.append(actions.MoveSouth())
return moves
示例11: exits
def exits(self):
"""Returns all move actions for adjacent tiles."""
available_exits = []
if world.tile_exists(self.x + 1, self.y):
available_exits.append("east")
if world.tile_exists(self.x - 1, self.y):
available_exits.append("west")
if world.tile_exists(self.x, self.y - 1):
available_exits.append("north")
if world.tile_exists(self.x, self.y + 1):
available_exits.append("south")
return available_exits
示例12: possible_moves
def possible_moves(self):
"""
Returns all possible move actions for adjacent tiles.
"""
moves = []
if world.tile_exists(self.x + 1, self.y):
moves.append(actions.MoveAstern())
if world.tile_exists(self.x - 1, self.y):
moves.append(actions.MoveFore())
if world.tile_exists(self.x, self.y + 1):
moves.append(actions.MoveAstarboard())
if world.tile_exists(self.x, self.y - 1):
moves.append(actions.MoveAport())
return moves
示例13: engine
def engine():
intro = title.choose_title()
raw_input(intro)
world.load_tiles()
player = Player()
# room_old to make sure a new room intro is given
room_old = None
while player.is_alive() and not player.victory:
room = world.tile_exists(player.loc_x, player.loc_y)
if room is not room_old:
print room.intro_text()
room_old = room
room.alter_player(player)
if player.is_alive() and not player.victory:
available_actions = room.available_actions()
# print '\tChoose from the following actions:'
# for action in available_actions:
# print '\t\t', action.name[0]
action_in = raw_input('\n\t> ').lower()
# if action_in == help or other special actions?
if action_in == 'exit' or action_in == 'quit':
sys.exit("\n\tSEE YOU SPACE COWBOY...\n")
for action in available_actions:
# problem with user just hitting enter?
if action_in in action.name:
player.do_action(action)
done = True
break
else:
done = False
continue
if not done:
print "\n\tSorry, I don't know what that means..."
示例14: move_npc
def move_npc(self, this_room, x, y, player):
#print "x: {} y: {}".format(x, y)
this_room.npcs.remove(self)
new_room = world.tile_exists(self.x + x, self.y + y)
new_room.npcs.append(self)
#print this_room.npcs
self.last.append((self.x, self.y))
self.update_nd()
self.x += x
self.y += y
#print "new loc {}, {}".format(self.x, self.y)
if player.location_x == this_room.x and player.location_y == this_room.y:
if x != 0:
if x > 0:
mydir = "east"
else:
mydir = "west"
else:
if y > 0:
mydir = "south"
else:
mydir = "north"
print "\t{} leaves the room to the {}.".format(self.name, mydir)
return
elif player.location_x == new_room.x and player.location_y == new_room.y:
#print "entering"
print "\t{} enters the room.".format(self.name)
return
return
示例15: sched
def sched(commands, available_actions, player, room):
print type(commands)
mapref = world.mapref()
for k in mapref:
print k
print mapref[commands[2]]
if commands[2] not in mapref:
print "\t{} is not the name of a room.".format(commands[2])
return
destx, desty = mapref[commands[2]]
temp = world.allrooms()
npclist =[]
for x, y in temp:
tmproom= world.tile_exists(x, y)
if tmproom and tmproom.npcs:
for npc in tmproom.npcs:
# if npc.shortnames[0] == commands[1]:
if commands[1] in npc.shortnames:
npc.dest = True
# npc.destx = mapref[commands[2][0]]
# npc.desty = mapref[commands[2][1]]
npc.destx = destx
npc.desty = desty
print "destination {}, {}".format(npc.destx, npc.desty)
return