本文整理汇总了Python中Base.Base.setPos方法的典型用法代码示例。如果您正苦于以下问题:Python Base.setPos方法的具体用法?Python Base.setPos怎么用?Python Base.setPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base.Base
的用法示例。
在下文中一共展示了Base.setPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import setPos [as 别名]
class Map:
def __init__(self, game, mapX = 100.0, mapY = 100.0, pylons = 3):
self.game = game
self.pylonList = []
self.walls = render.attachNewNode("Walls")
#subtract 10 so pylons won't spawn inside walls
self.makeRndPylons( self.game, pylons, (mapX - 10), (mapY - 10) )
#self.makePylon( self.game, 100, 0, 0)
self.makeRndWalls( self.game, pylons/2, (mapX - 10), (mapY - 10) )
#subtract 10 so bases won't spawn inside walls
self.base1 = self.makeBase( self.game, (mapY - 10) )
self.base2 = self.makeBase( self.game, -(mapY - 10) )
self.makeBoundaryWalls( self.game, mapX, mapY )
self.makeAntiGravityPlate( self.game, (2*mapX), (2*mapY) )
def getPylonList(self):
return self.pylonList
def getShiplist(self):
return self.shipList
def getBase1(self):
return self.base1
def getBase2(self):
return self.base2
def makeBoundaryWalls(self, game, mapX = 100.0, mapY = 100.0):
wall1 = BigWall(game, 2*mapX)
wall1.setPos( Vec3(0, -mapY, 0) )
wall1.visualNode.reparentTo(self.walls)
wall2 = BigWall(game, 2*mapX)
wall2.setPos( Vec3(0, mapY, 0) )
wall2.visualNode.reparentTo(self.walls)
wall3 = BigWall(game, 2*mapY)
wall3.setRotation( 90 )
wall3.setPos( Vec3(-mapX , 0, 0) )
wall3.visualNode.reparentTo(self.walls)
wall4 = BigWall(game, 2*mapY)
wall4.setRotation( 90 )
wall4.setPos( Vec3(mapX , 0, 0) )
wall4.visualNode.reparentTo(self.walls)
def makePylon(self, game, power, x, y):
self.pylon = Pylon( game, power )
self.pylon.setPos( Vec3(x, y, 0) )
self.pylon.addToPylonList( self.pylonList )
def makeRndPylons(self, game, amount, mapX, mapY):
#create n amount of random powered pylons ( power is something between -game.MAX_PYLON_POWER and game.MAX_PYLON_POWER )
for x in range(amount):
self.makePylon( game,
random.randrange(-self.game.MAX_PYLON_POWER, self.game.MAX_PYLON_POWER),
random.randrange( -mapX, mapX ), random.randrange( -mapY, mapY )
)
def makeRndWalls(self, game, amount, mapX, mapY, minWallWidth = 40.0, maxWallWidth=60.0):
for x in range(amount):
wall = BigWall( game, random.randrange(minWallWidth, maxWallWidth) )
wall.setPos( Vec3(random.randrange( -mapX, mapX ), random.randrange( -mapY, mapY ), 0) )
wall.visualNode.reparentTo(self.walls)
def makeBase(self, game, posY, posX = 0):
#spawns a base
self.base = Base( game )
self.base.setPos( Vec3( posX, posY, 15), Vec3( posX, posY, 0) )
return self.base
#ks. konstruktorissa self.base1 ja 2
# saadaan tunnistettua kumman base on kyseessa, 1-pelaajan vaiko 2
def makeAntiGravityPlate(self, game, mapX, mapY):
self.agplate = AntiGravityPlate( game, mapX, mapY )
self.agplate.setPos( Vec3( 0, 0, -5) )
示例2: __init__
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import setPos [as 别名]
class Map:
def __init__(self, game, mapX = 100.0, mapY = 100.0, pylons = 3):
self.game = game
self.pylonList = []
#self.baseList = []
#subtract 10 so pylons won't spawn inside walls
self.makeRndPylons( self.game, pylons, (mapX - 10), (mapY - 10) )
#subtract 10 so bases won't spawn inside walls
self.base1 = self.makeBase( self.game, (mapY - 10) )
self.base2 = self.makeBase( self.game, -(mapY - 10) )
self.makeBoundaryWalls( self.game, mapX, mapY )
self.makeAntiGravityPlate( self.game, mapX, mapY )
def getPylonList(self):
return self.pylonList
def getBase1(self):
return self.base1
def getBase2(self):
return self.base2
def makeBoundaryWalls(self, game, MapX = 100.0, MapY = 100.0, WallLength = 50.0 ):
WALLS = range(1, int(2*((MapX / WallLength) + 1)))
for Wall in WALLS:
BigWall1 = bigWall(game)
BigWall1.setPos( Vec3(-MapX + (WallLength*Wall)-(WallLength / 2) , -MapY, 0) )
BigWall2 = bigWall(game)
BigWall2.setPos( Vec3(-MapX + (WallLength*Wall)-(WallLength / 2) , +MapY, 0) )
BigWall3 = bigWall(game)
BigWall3.setRotation( 90 )
BigWall3.setPos( Vec3(-MapX , -MapY + (WallLength*Wall)-(WallLength / 2), 0) )
BigWall4 = bigWall(game)
BigWall4.setRotation( 90 )
BigWall4.setPos( Vec3(+MapX , -MapY + (WallLength*Wall)-(WallLength / 2), 0) )
#self.wallList.append(BigWall1)
#self.wallList.append(BigWall2)
#self.wallList.append(BigWall3)
def makePylon(self, game, power, x, y):
#spawns a new pylon and adds it to pylonList
self.pylon = Pylon( game, power )
self.pylon.setPos( Vec3(x, y, 0) )
self.pylon.addToPylonList( self.pylonList )
def makeRndPylons(self, game, amount, mapX, mapY):
#create n amount of random powered pylons ( power is something between -100 and 100 )
for x in range(amount):
# print str(x) + " loop"
self.makePylon( game, random.randrange(-100, 100), random.randrange( -mapX, mapX ), random.randrange( -mapY, mapY ) )
def makeBase(self, game, posY, posX = 0):
#spawns a base
self.base = Base( game )
self.base.setPos( Vec3( 0, posY, 0) )
return self.base
def makeAntiGravityPlate(self, game, mapX, mapY):
#spawns an AntiGravityPlate
self.agplate = AntiGravityPlate( game, mapX, mapY )
self.agplate.setPos( Vec3( 0, 0, -5) )
return self.agplate