def setSky(self, skyName): if self.sky: self.sky.destroy() self.sky = SkyBox() self.sky.load(skyName) self.sky.set(skyName)
def __init__(self, gamemanager): # GameManager, from game.py self.gm = gamemanager # ODE base setup self.world = makeWorld() self.space = OdeSimpleSpace() self.space.setAutoCollideWorld(self.world) self.space.setCollisionEvent("ode-collision") self.accept("ode-collision", self.onCollision) self.contactGroup = OdeJointGroup() self.space.setAutoCollideJointGroup(self.contactGroup) #--------------------------------------------------------------- # space objects lists and dics #--------------------------------------------------------------- self.shipList = [] self.shipDic = {} self.laserList = [] self.laserDic = {} self.lootList = [] self.lootDic = {} self.baseList = [] self.baseDic = {} #--------------------------------------------------------------- self.dtCumul = 0.0 self.stepSize = 1.0 / 75.0 #--------------------------------------------------------------- # crosshair stuff, to aim guns and click on 3D objects with the mouse. # This same crosshair is used when on the ground for GUI too, for now. #--------------------------------------------------------------- self.gm.crosshair.setMode(1) self.currentTargetDest = None self.currentTargetNP = None self.picker = OdePicker(self) #------------------------------------------------------------------- # GUI #------------------------------------------------------------------- self.gui = SpaceGui(self.gm.playerData) #--------------------------------------------------------------- # input handling self.keyMap = {} self.acceptAll() #--------------------------------------------------------------- # some loot for i in range(10): cube = Cube(self, 5) #cube = Sphere(self, 5) cube.setPos((i * 0.02, i * 0.02, 5.5 * i + 2.51)) name = "Cube " + str(i) cube.name = name self.lootList.append(cube) self.lootDic[cube.geom.getId()] = cube #--------------------------------------------------------------- # player ship self.ship = Ship(self, self.gm.playerData.ship) self.ship.setPos((0, -20, 12.51)) #--------------------------------------------------------------- # bases self.addBase("hesperida") #--------------------------------------------------------------- # camera self.mode = "manual" self.camHandler = SpaceCamManager(self) self.camHandler.update() #--------------------------------------------------------------- # radar self.radar = OdeRadar(self) #--------------------------------------------------------------- # light self.light = LightManager() self.light.lightCenter.reparentTo(self.ship.model) #--------------------------------------------------------------- # stardust cloud surrounding the player ship #self.PE = ParticleEngine(self.ship.model.getPos(), nb=100, ray=100, move = True) self.PE = ParticleEngine(self.ship.model, nb=40, ray=50, move=True) self.PE.stop() #--------------------------------------------------------------- # trail of the player ship, TODO : move that to the OdeShip class and update ShipData to handle it self.trailPE = AriTrail(self.ship.model, 20, 0.0) #self.trailPE2 = AriTrail(self.gun2,10,0.0) #skyName = "skyBox06" skyName = "purple0" self.sky = SkyBox() self.sky.load(skyName) self.sky.set(skyName) self.currentSkyName = skyName self.sky.stop() #self.sky.currentModel.hide(BitMask32.bit(1)) # BG music self.bgMusic = spaceBgMusic["hesperida_space"] self.NPCTimer = 0.0 #self.accept("t", self.step) #self.start() self.task = None self.stop()