本文整理汇总了Python中direct.showbase.RandomNumGen.RandomNumGen.randrange方法的典型用法代码示例。如果您正苦于以下问题:Python RandomNumGen.randrange方法的具体用法?Python RandomNumGen.randrange怎么用?Python RandomNumGen.randrange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.showbase.RandomNumGen.RandomNumGen
的用法示例。
在下文中一共展示了RandomNumGen.randrange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate
# 需要导入模块: from direct.showbase.RandomNumGen import RandomNumGen [as 别名]
# 或者: from direct.showbase.RandomNumGen.RandomNumGen import randrange [as 别名]
def generate(self):
DistributedPartyActivity.generate(self)
self.notify.info('localAvatar doId: %s' % base.localAvatar.doId)
self.notify.info('generate()')
self._generateFrame = globalClock.getFrameCount()
self._id2gen = {}
self._orderedGenerations = []
self._orderedGenerationIndex = None
rng = RandomNumGen(self.doId)
self._generationSeedBase = rng.randrange(1000)
self._lastDropTime = 0.0
return
示例2: MazeSuit
# 需要导入模块: from direct.showbase.RandomNumGen import RandomNumGen [as 别名]
# 或者: from direct.showbase.RandomNumGen.RandomNumGen import randrange [as 别名]
#.........这里部分代码省略.........
self.nextTX = self.TX
self.nextTY = self.TY
self.suit.setPos(self._MazeSuit__getWorldPos(self.TX, self.TY))
self.suit.setHpr(self.directionHs[self.direction], 0, 0)
self.suit.reparentTo(render)
self.suit.pose(self._walkAnimName, 0)
self.suit.loop('neutral')
def offstage(self):
self.suit.reparentTo(hidden)
def startWalkAnim(self):
self.suit.loop(self._walkAnimName)
speed = float(self.maze.cellWidth) / self.cellWalkDuration
self.suit.setPlayRate(speed / self.DEFAULT_SPEED, self._walkAnimName)
def _MazeSuit__applyDirection(self, dir, TX, TY):
if self.DIR_UP == dir:
TY += 1
elif self.DIR_DOWN == dir:
TY -= 1
elif self.DIR_LEFT == dir:
TX -= 1
elif self.DIR_RIGHT == dir:
TX += 1
return (TX, TY)
def _MazeSuit__chooseNewWalkDirection(self, unwalkables):
if not self.rng.randrange(self._walkSameDirectionProb):
(newTX, newTY) = self._MazeSuit__applyDirection(self.direction, self.TX, self.TY)
if self.maze.isWalkable(newTX, newTY, unwalkables):
return self.direction
if self.difficulty >= 0.5:
if not self.rng.randrange(self._walkTurnAroundProb):
oppositeDir = self.oppositeDirections[self.direction]
(newTX, newTY) = self._MazeSuit__applyDirection(oppositeDir, self.TX, self.TY)
if self.maze.isWalkable(newTX, newTY, unwalkables):
return oppositeDir
candidateDirs = [
self.DIR_UP,
self.DIR_DOWN,
self.DIR_LEFT,
self.DIR_RIGHT]
candidateDirs.remove(self.oppositeDirections[self.direction])
while len(candidateDirs):
dir = self.rng.choice(candidateDirs)
(newTX, newTY) = self._MazeSuit__applyDirection(dir, self.TX, self.TY)
if self.maze.isWalkable(newTX, newTY, unwalkables):
return dir
candidateDirs.remove(dir)
return self.oppositeDirections[self.direction]
def getThinkTimestampTics(self, curTic):
if curTic < self.nextThinkTic: