本文整理汇总了Python中room.Room.roomId方法的典型用法代码示例。如果您正苦于以下问题:Python Room.roomId方法的具体用法?Python Room.roomId怎么用?Python Room.roomId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类room.Room
的用法示例。
在下文中一共展示了Room.roomId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addRoom
# 需要导入模块: from room import Room [as 别名]
# 或者: from room.Room import roomId [as 别名]
def addRoom(self, adjRoom, type, direction=NO_DIR):
# print "Add Room Called"
# assign the room new coords relative to the adjacent room
gridCoord = [0, 0]
# if the new room is to the west of adjRoom
if direction == WEST:
gridCoord[x] = adjRoom.gridCoord[x] - 1
gridCoord[y] = adjRoom.gridCoord[y]
# if the new room is to the north of adjRoom
elif direction == NORTH:
gridCoord[x] = adjRoom.gridCoord[x]
gridCoord[y] = adjRoom.gridCoord[y] - 1
# if the new room is to the east of adjRoom
elif direction == EAST:
gridCoord[x] = adjRoom.gridCoord[x] + 1
gridCoord[y] = adjRoom.gridCoord[y]
# if the new room is to the south of adjRoom
elif direction == SOUTH:
gridCoord[x] = adjRoom.gridCoord[x]
gridCoord[y] = adjRoom.gridCoord[y] + 1
alreadyExists = False
for room in self.rooms:
if room.gridCoord == gridCoord:
alreadyExists = True
if not alreadyExists:
# make the room
newRoom = Room(direction, type, [None, None, None, None], gridCoord)
newRoom.doors[opposite(direction)] = Door(opposite(direction))
adjRoom.doors[direction] = Door(direction)
# update pointers
if direction != NO_DIR:
adjRoom.adjRooms[direction] = newRoom
newRoom.adjRooms[opposite(direction)] = adjRoom
newRoom.roomId = len(Dungeon.floorKeys)
room = r.randint(0, len(self.rooms) - 1)
xPos = r.randint(Room.currentRoom.boundingBox[WEST] + Key.keyImg.width/2,
Room.currentRoom.boundingBox[EAST] - Key.keyImg.width/2)
yPos = r.randint(Room.currentRoom.boundingBox[NORTH] + Key.keyImg.width/2,
Room.currentRoom.boundingBox[SOUTH] - Key.keyImg.width/2)
newKey = Key(xPos, yPos, self.rooms[room])
newRoom.rightKey = newKey
Dungeon.floorKeys.append(newKey)
self.rooms.append(newRoom)
self.linkRooms(newRoom)
return True if not alreadyExists else False