本文整理汇总了Python中Map.getMap方法的典型用法代码示例。如果您正苦于以下问题:Python Map.getMap方法的具体用法?Python Map.getMap怎么用?Python Map.getMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.getMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameManager
# 需要导入模块: import Map [as 别名]
# 或者: from Map import getMap [as 别名]
class GameManager(object):
def __init__(self, mapFileName):
self._map = Map(mapFileName, 3);
self._lastTime = time.time();
def start(self):
gevent.spawn(self.update, 0.01);
gevent.spawn(self.spawnMonster, 3);
def update(self, interval):
while True:
gevent.sleep(interval);
elapsedTime = time.time() - self._lastTime;
self._map.update(elapsedTime);
self._map.clearCorpse();
self._lastTime = time.time();
def spawnMonster(self, interval):
while True:
gevent.sleep(interval);
self._map.spawnMonster();
def movePlayer(self, player, direction):
self._map.movePlayer(player, direction);
def addPlayer(self, player):
self._map.playerList.append(player);
def removePlayer(self, player):
self._map.playerList.remove(player);
def getPlayerList(self):
return self._map.playerList;
def getMonsterList(self):
return self._map.monsterList;
def getMap(self):
return self._map.getMap();
示例2: Map
# 需要导入模块: import Map [as 别名]
# 或者: from Map import getMap [as 别名]
#.........这里部分代码省略.........
points.append([self.sensor.getDistance(),self.botAngle])
self.movement.turn(self.turnAngle)
self.botAngle = self.botAngle+self.turnAngle
time.sleep(1)
if self.botAngle >= 360:
self.botAngle = self.botAngle-360
#self.movement.turn(self.turnAngle)
#self.botAngle = self.botAngle+self.turnAngle
#break
#if self.botAngle == 0:
# break
return points
def mapRoom90(self):
self.turnAngle = 90
while(not self.room.isMapped()):
points = self.sense()
self.botPos = self.room.updateMap(points)
self.room.fillMap90()
nextDir = self.room.nextRoute90()
if nextDir=="U":
if self.botAngle!=0:
self.movement.turn(360-self.botAngle)
self.botAngle=0
self.movement.move(MAXVIEW-20)
self.botPos[0]=self.botPos[0]-MAXVIEW+20
self.room.updatePos(self.botPos)
elif nextDir=="D":
if self.botAngle!=180:
self.movement.turn(180-self.botAngle)
self.botAngle=180
self.movement.move(MAXVIEW-20)
self.botPos[0]=self.botPos[0]+MAXVIEW-20
self.room.updatePos(self.botPos)
elif nextDir=="R":
if self.botAngle!=90:
self.movement.turn(90-self.botAngle)
self.botAngle=90
self.movement.move(MAXVIEW-20)
self.botPos[1]=self.botPos[1]+MAXVIEW-20
self.room.updatePos(self.botPos)
elif nextDir=="L":
if self.botAngle!=270:
self.movement.turn(270-self.botAngle)
self.botAngle=270
self.movement.move(MAXVIEW-20)
self.botPos[1]=self.botPos[1]-MAXVIEW+20
self.room.updatePos(self.botPos)
elif nextDir == None:
self.room.showRoom()
self.com.sendMessage("data")
time.sleep(1)
u=0
d=0
l=0
r=0
m = self.room.getMap()
for i in range(len(m)):
if m[i][self.botPos[1]]==1 and i<self.botPos[0]:
u=i
break
for i in range(len(m)):
if m[i][self.botPos[1]]==1 and i>self.botPos[0]:
d=i
break
for i in range(len(m[0])):
if m[self.botPos[0]][i]==1 and i<self.botPos[1]:
l = i
break
for i in range(len(m[0])):
if m[self.botPos[0]][i]==1 and i>self.botPos[1]:
r = i
break
print u,d,l,r
self.com.updateMap((l,r,u,d))
#self.com.updateMap(self.room.getMap())
time.sleep(5)
self.com.sendMessage("bot")
time.sleep(1)
self.com.sendBotLocation((self.botPos[0],self.botPos[1],self.botAngle))
time.sleep(1)
self.com.sendMessage("mes")
time.sleep(1)
self.com.sendMessage("Mapping Complete!")
break
#complete
'''
self.com.sendMessage("data")
time.sleep(1)
self.com.updateMap(self.room.getMap())
time.sleep(5)
self.com.sendMessage("bot")
time.sleep(1)
self.com.sendBotLocation((self.botPos[0],self.botPos[1],self.botAngle))
time.sleep(1)
'''
#print "Location: " + str(self.move.location)
'''