本文整理汇总了Python中world.tile_exists函数的典型用法代码示例。如果您正苦于以下问题:Python tile_exists函数的具体用法?Python tile_exists怎么用?Python tile_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tile_exists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:jddaly2011,项目名称:adv.py,代码行数:26,代码来源:game.py
示例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
开发者ID:jddaly2011,项目名称:adventure,代码行数:27,代码来源:working-game.py
示例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
开发者ID:jddaly2011,项目名称:adventure,代码行数:28,代码来源:bak-npcs.py
示例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()
开发者ID:jddaly2011,项目名称:adv.py,代码行数:25,代码来源:cmdgame2.py
示例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!")
开发者ID:manuelpepe,项目名称:TextAdventureGame,代码行数:31,代码来源:game.py
示例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
开发者ID:growlitheharpo,项目名称:text-adventure-tut,代码行数:25,代码来源:Main.py
示例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.')
开发者ID:CopperGenie,项目名称:swordfable,代码行数:27,代码来源:game.py
示例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()
开发者ID:BigGingerJake,项目名称:a_short_game,代码行数:9,代码来源:player.py
示例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
开发者ID:manuelpepe,项目名称:TextAdventureGame,代码行数:12,代码来源:tiles.py
示例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
开发者ID:wackyzacky42,项目名称:TxtAdv,代码行数:12,代码来源:tiles.py
示例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
开发者ID:jddaly2011,项目名称:adventure,代码行数:14,代码来源:bak-npcs.py
示例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
开发者ID:TheKingInYellow,项目名称:TheTemple,代码行数:14,代码来源:tiles.py
示例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..."
开发者ID:TheKingInYellow,项目名称:TheTemple,代码行数:35,代码来源:temple.py
示例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
开发者ID:jddaly2011,项目名称:adventure,代码行数:33,代码来源:bak-npcs.py
示例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
开发者ID:jddaly2011,项目名称:adventure,代码行数:26,代码来源:schedule.py
示例16: default
def default(self, player, world):
self.moves += 1
self.check_sked(player, world)
if self.dest:
#print self.shortnames[0]
#print self.x, self.y
#print self.nd
this_room = world.tile_exists(self.x, self.y)
#print this_room.npcs
if self.x == self.dest_x and self.y == self.dest_y: #we made it
#print "Trip completed {}, {}".format(self.x, self.y)
self.nd = {}
self.dest = None
return
if self.moves % 2 != 0: #wait two moves before moving
#print "WAITING~~"
return
else:
#print "MOVING"
available_exits = self.exits()
#print "Exits: {}".format(available_exits)
x, xdir, y, ydir = self.get_dir()
#print self.nd
if len(available_exits) == 1:
func = "self.move_{}(this_room, player)".format(available_exits[0])
exec func
return
if xdir and (self.x + x, self.y) not in self.last:
if xdir in available_exits:
func = "self.move_{}(this_room, player)".format(xdir)
exec func
return
elif ydir and (self.x, self.y + y) not in self.last:
if ydir in available_exits:
func = "self.move_{}(this_room, player)".format(ydir)
exec func
return
elif xdir and self.nd[(self.x + x, self.y)] < 2:
if xdir in available_exits:
func = "self.move_{}(this_room, player)".format(xdir)
exec func
return
elif ydir:
if (self.x, self.y + y) in self.nd:
#print nd
if self.nd[(self.x, self.y + y)] < 2:
if ydir in available_exits:
func = "self.move_{}(this_room, player)".format(xdir)
exec func
return
else:
if ydir in available_exits:
func = "self.move_{}(this_room, player)".format(xdir)
exec func
return
开发者ID:jddaly2011,项目名称:adventure,代码行数:60,代码来源:bak-npcs.py
示例17: adjacent_moves
def adjacent_moves(self):
"""Returns all move actions for adjacent tiles."""
# allows a list to be made with the name 'moves'
moves = []
# Each 'if' statement tests if a til is present in the given direction
# if True then the direction wil will be appended to the list for latter
# display 'actions' refers to the actions.py class file. x is east/west
# and y is north/south. I'm not sure how it does it. I'll need to look
# at actions.py and world.py
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())
# displays the moves that are available to the player
return moves
开发者ID:Owslla,项目名称:PyTF,代码行数:19,代码来源:ex23.py
示例18: 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
def available_actions(self):
#returns all of the available actions in this room
moves = self.adjacent_moves()
moves.append(actions.ViewInventory())
return moves
开发者ID:JoeyandWalter,项目名称:ModelGame,代码行数:19,代码来源:tiles.py
示例19: exits_text
def exits_text(self):
"""Returns all move actions for adjacent tiles."""
exits = []
if world.tile_exists(self.x + 1, self.y):
exits.append("east")
if world.tile_exists(self.x - 1, self.y):
exits.append("west")
if world.tile_exists(self.x, self.y - 1):
exits.append("north")
if world.tile_exists(self.x, self.y + 1):
exits.append("south")
if len(exits) == 1:
print "\tYou may exit to the {}".format(exits[0])
elif len(exits) == 2:
print "\tThere are exits to the {} and {}".format(exits[0], exits[1])
elif len(exits) == 3:
print "\tThere are exits to the {}, {}, and {}".format(exits[0], exits[1], exits[2])
else:
print "\tThere are exits to the {}, {}, {}, and {}".format(exits[0], exits[1], exits[2], exits[3])
开发者ID:jddaly2011,项目名称:adv.py,代码行数:19,代码来源:tiles.py
示例20: 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:
#loop starts here
room = world.tile_exists(player.location_x, player.location_y)
room.modify_player(player)
#check again bc room could change player state
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
开发者ID:QAadventures,项目名称:Ariel-s-QA-Adventure,代码行数:20,代码来源:game.py
注:本文中的world.tile_exists函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论