def __init__(self): ShowBase.__init__(self) #setting background self.environ = self.loader.loadModel("models/world") #Reparent the model to render #self.environ.reparentTo(self.render) #Apply scale and position transforms on the model self.environ.setScale(1000, 1000, 1000) self.environ.setPos(0, 0, 0) self.gameTask = taskMgr.add(self.gameLoop, "gameLoop") base.disableMouse() base.camera.setPos(0, -300, 100) base.camera.lookAt(0, 0, 0) slight = Spotlight('slight') slight.setColor(VBase4(1, 1, 1, 1)) lens = PerspectiveLens() slight.setLens(lens) self.shipList = [ Xwing("xwing1"), # Ywing("ywing1"), # Awing("awing1")#, # Bwing("bwing1"), # TieFighter("tiefighter1"), # TieInterceptor("tieinterceptor1") ] lightColors = [ Vec4(0.9, 0.9, 0.9, 1), Vec4(1, 1, 0, 1), Vec4(1, 0, 0, 1), Vec4(0, 0, 1, 1), Vec4(0.4, 0.4, 0.4, 1), Vec4(0.1, 0.1, 0.1, 1) ] for i, ship in enumerate(self.shipList): ship.reparentTo(render) ship.setPos(Point3(i * 10, 0, 0)) directionalLight = DirectionalLight('directionalLight') directionalLight.setColor(lightColors[i]) directionalLightNP = render.attachNewNode(directionalLight) directionalLightNP.setHpr(180, -20, 0) ship.setLight(directionalLightNP) self.count = 0 self.fire = False
def __init__(self): ShowBase.__init__(self) base.disableMouse() # base.camera.setPos(0, 0, 0) dl = DirectionalLight('dLight') dl.setColor(Vec4(0.1, 0.1, 0.1, 1)) dlNP = render.attachNewNode(dl) dlNP.setPos(1000, 1000, 0) al = AmbientLight('alight') al.setColor(Vec4(0.3, 0.3, 0.3, 1)) alNP = render.attachNewNode(al) pl = PointLight('plight') pl.setColor(VBase4(0.2, 0.2, 0.2, 1)) plNP = render.attachNewNode(pl) plNP.setPos(100, 100, 100) render.setLight(plNP) self.shipList = [ # Awing('awing1'), # Bwing('bwing1'), # Ywing("ywing1"), Xwing('xwing1'), TieInterceptor("interceptor1") #, #Xwing('xwing1') ] # xwing = Xwing("xwing1") # tie = TieInterceptor("tie1") # self.shipList = [xwing, tie] # xwing.weaponSystem.fireWeapon() for i, ship in enumerate(self.shipList): ship.reparentTo(render) ship.setScale(2) ship.setPos(Point3(i * 0, i * 50, i * 0)) # ship.setLight(dlNP) ship.setLight(alNP) base.camera.setPos(0, 1000, 0) base.camera.lookAt(0, 0, 0) taskMgr.add(self.clearSpaceFlag, 'clearFlags')
def __init__(self): ShowBase.__init__(self) self.gameTask = taskMgr.add(self.gameLoop, "gameLoop") base.disableMouse() base.camera.setPos(500, 500, 2000) base.camera.lookAt(500, 500, 0) slight = Spotlight('slight') slight.setColor(VBase4(1, 1, 1, 1)) lens = PerspectiveLens() slight.setLens(lens) # create rebel ships self.rebels = [Xwing('xwing' + str(x)) for x in xrange(10)] self.rebels += [Ywing('ywing' + str(x)) for x in xrange(10)] self.rebels += [Awing('awing' + str(x)) for x in xrange(10)] self.rebels += [Bwing('bwing' + str(x)) for x in xrange(10)] # create imperial ships self.imperials = [ TieFighter('tiefighter' + str(x)) for x in xrange(10) ] self.imperials += [ TieInterceptor('tieinterceptor' + str(x)) for x in xrange(10) ] self.shipList = [] self.shipList += self.rebels + self.imperials for i, ship in enumerate(self.shipList): ship.reparentTo(render) ship.setScale(2) ship.setPos( Point3(random() * 1000, random() * 1000, random() * 1000)) directionalLight = DirectionalLight('directionalLight') directionalLightNP = render.attachNewNode(directionalLight) directionalLightNP.setHpr(180, -20, 0) ship.setLight(directionalLightNP)
def __init__(self): ShowBase.__init__(self) base.disableMouse() # base.camera.setPos(0, 0, 0) dl = DirectionalLight('dLight') dl.setColor(Vec4(0.1, 0.1, 0.1, 1)) dlNP = render.attachNewNode(dl) dlNP.setPos(1000, 1000, 0) al = AmbientLight('alight') al.setColor(Vec4(0.3, 0.3, 0.3, 1)) alNP = render.attachNewNode(al) pl = PointLight('plight') pl.setColor(VBase4(0.2, 0.2, 0.2, 1)) plNP = render.attachNewNode(pl) plNP.setPos(100, 100, 100) render.setLight(plNP) xwing = Xwing("xwing1") tie = TieFighter("tie1") awing = Awing('awing1') self.shipList = [xwing, tie, awing] # xwing.weaponSystem.fireWeapon() for i, ship in enumerate(self.shipList): ship.reparentTo(render) ship.setScale(2) ship.setPos(Point3(i * 0, i * 400, i * 0)) # ship.setLight(dlNP) ship.setLight(alNP) base.camera.setPos(tie.getPos() + Vec3(20, 400, 0)) base.camera.lookAt(xwing.getPos()) taskMgr.add(self.clearSpaceFlag, 'clearFlags') self.camFilter = LpfVec3(Vec3(0, 0, 0), 10)
def __init__(self): ShowBase.__init__(self) self.cc = CentralController() self.gameTask = taskMgr.add(self.cc.run, "cc.run") base.disableMouse() base.camera.setPos(-20, 50, 70) base.camera.lookAt(20, 0, 0) slight = Spotlight('slight') slight.setColor(VBase4(1, 1, 1, 1)) lens = PerspectiveLens() slight.setLens(lens) self.shipList = [ Xwing("models/ywing", 0.3, "xwing1"), Ywing("models/xwing", 0.3, "ywing1") ] lightColors = [Vec4(0.9, 0.9, 0.9, 1), Vec4(1, 1, 0, 1)] for i, ship in enumerate(self.shipList): ship.reparentTo(render) ship.setScale(2) ship.setPos(Point3(i * 20, 0, 0)) directionalLight = DirectionalLight('directionalLight') directionalLight.setColor(lightColors[i]) directionalLightNP = render.attachNewNode(directionalLight) directionalLightNP.setHpr(180, -20, 0) ship.setLight(directionalLightNP) self.cc.addObject(ship) self.count = 0
def __init__(self): ShowBase.__init__(self) self.gameTask = taskMgr.add(self.flyCircles, "circles") base.disableMouse() base.camera.setPos(50, 100, 800) base.camera.lookAt(0, 0, 0) dl = DirectionalLight('dLight') dl.setColor(Vec4(0.1, 0.1, 0.1, 1)) dlNP = render.attachNewNode(dl) dlNP.setPos(1000, 1000, 0) al = AmbientLight('alight') al.setColor(Vec4(0.3, 0.3, 0.3, 1)) alNP = render.attachNewNode(al) pl = PointLight('plight') pl.setColor(VBase4(0.2, 0.2, 0.2, 1)) plNP = render.attachNewNode(pl) plNP.setPos(100, 100, 100) render.setLight(plNP) self.shipList = [Bwing("xwing1"), TieInterceptor("tie1")] for i, ship in enumerate(self.shipList): ship.reparentTo(render) ship.setScale(2) ship.setPos(Point3(i * 10, i * 0, i * 0)) # ship.setLight(dlNP) ship.setLight(alNP) self.count = 0 self.iter = 0
def __init__(self): ShowBase.__init__(self) self.cc = CentralController() self.gameTask = taskMgr.add(self.flyCircles, "circles") base.disableMouse() base.camera.setPos(1000, 100, 4000) base.camera.lookAt(200, 1000, 0) slight = Spotlight('slight') slight.setColor(VBase4(1, 1, 1, 1)) lens = PerspectiveLens() slight.setLens(lens) self.rebels = [] self.imperials = [] # add rebel ships self.rebels += [Xwing('xwing' + str(x)) for x in xrange(1)] #self.rebels += [Ywing('ywing' + str(x)) for x in xrange(1)] #self.rebels += [Awing('awing' + str(x)) for x in xrange(1)] #self.rebels += [Bwing('bwing' + str(x)) for x in xrange(1)] # add imperial ships self.imperials += [ TieFighter('tiefighter' + str(x)) for x in xrange(1) ] #self.imperials += [TieInterceptor('tieinterceptor' + str(x)) for x in xrange(2)] # add rebel ships self.rebels += [Xwing('xwing' + str(x) + 'second') for x in xrange(1)] #self.rebels += [Ywing('ywing' + str(x) + 'second') for x in xrange(1)] #self.rebels += [Awing('awing' + str(x) + 'second') for x in xrange(1)] #self.rebels += [Bwing('bwing' + str(x) + 'second') for x in xrange(1)] # add more imperial ships #self.imperials += [TieFighter('tiefighter' + str(x) + 'second') for x in xrange(2)] self.imperials += [ TieInterceptor('tieinterceptor' + str(x) + 'second') for x in xrange(1) ] # create ship list self.shipList = self.rebels + self.imperials #self.shipList = [ # Xwing("xwing1"), TieFighter("tie1"), Bwing("xwing2")] lightColors = [ Vec4(0.9, 0.9, 0.9, 1), Vec4(0.9, 0.9, 0.9, 1), ] for i, ship in enumerate(self.shipList): ship.reparentTo(render) ship.setScale(2) ship.setPos(Point3(i * 50 + 50, i * 100 + 100, i * 50 + 50)) directionalLight = DirectionalLight('directionalLight') directionalLightNP = render.attachNewNode(directionalLight) directionalLightNP.setHpr(180, -20, 0) ship.setLight(directionalLightNP) #ship.navSystem.setPursue() self.cc.addObject(ship) self.count = 0 self.iter = 0 camera.lookAt(self.shipList[1].getPos())