def __init__(self, pos, world): self.id = next(Dorf.idgen) self.world = world self.node = loader.loadModel('media/models/dorfPH.egg') self.text = core.TextNode('dorf') self.text.setText('Dorf {}'.format(self.id)) self.text.setAlign(core.TextNode.ACenter) self.text.setTextColor(1, 1, 0.5, 1) self.text.setShadow(0.1, 0.1) self.text.setShadowColor(0, 0, 0, 0.8) self.textnode = self.node.attachNewNode(self.text) self.textnode.setBillboardPointEye() self.textnode.setPos(0, 0, 1.1) self.textnode.setScale(0.4) self.textnode.setDepthWrite(False) self.textnode.setDepthTest(False) self.textnode.setShaderOff() self.x = int(pos.x) self.y = int(pos.y) self.z = 0 self.next = None self.dir = (1, 0) taskMgr.doMethodLater(0.5, self.move, 'Move dorf') self.set_z(int(pos.z)) self.node.setPos(pos.x, pos.y, 0) self.particles = ParticleEffect() self.particles.loadConfig('media/sparks.ptf') self.particles.reparentTo(self.node)
def leakTask(task=None, leakTaskName=leakTaskName): base = getBase() taskMgr.add(nullTask, uniqueName(leakTaskName)) taskMgr.doMethodLater(1 << 31, nullDoLater, uniqueName(leakDoLaterName)) taskMgr.doMethodLater(10, leakTask, 'doLeakTask-%s' % serialNum()) if task: return task.done
def collide1(self,f,collEntry): if f in self.highlighted_indices: self.players[f].setColorScale(0,1,0,1) self.tar.setColorScale(0.2,0.2,0.2,1) self.tar.setAlphaScale(0.7) self.contacts[f] = True taskMgr.doMethodLater(self.delay,self.too_long,'too_long%d' % f,extraArgs = [f])
def start(self): self.time = TIME self.text = str(self.time) taskMgr.doMethodLater(1, self.update, 'Update Timer Object', uponDeath=self.task_stopped)
def start_game(self): """ Called upon the game starting for the first time """ self.notify.debug(f"[start_game] Starting game: {self.gid}") # set variables self.started = True self.day_count = 1 # create AI while self.get_player_count() < MAX_PLAYERS: self.add_ai() # fix people who haven't updated their name for p in self.players: if p.name == "???": self.set_name(p.local_id, p.random_name()) # assign killer # TODO # make it random and not just the first player - but i need to debug self.killer = self.players[0].local_id # tell players self.message_all_players(dg_start_game(self)) # tell killer self.message_killer(dg_you_are_killer()) # create task to change time of day taskMgr.doMethodLater(TIME, self.change_time, "DayNight Cycle {}".format(self.gid))
def __init__(self, debug_ui): Notifier.__init__(self, "ui-single-player") self.debug_ui = debug_ui taskMgr.doMethodLater(1, self.update_info, "UpdateSinglePlayerInfo") self.pid = None self.txts = [] self.btns = [] # texts self.txt_pid = OnscreenText(text="", pos=(1, .8), scale=0.1, fg=(1, 1, 1, 1)) self.txt_gid = OnscreenText(text="", pos=(1, .7), scale=0.1, fg=(1, 1, 1, 1)) # texts append self.txts.append(self.txt_pid) self.txts.append(self.txt_gid) # buttons self.btn_gid = None # buttons append self.btns.append(self.btn_gid) self.notify.info("[__init__] Created SinglePlayer")
def stop(self): """ This method can be called by JavaScript to stop the application. """ # We defer the actual exit for a few frames, so we don't raise # an exception and invalidate the JavaScript call; and also to # help protect against race conditions as the application # shuts down. taskMgr.doMethodLater(0.5, sys.exit, 'exit')
def enterGotoHq(self): self.systemMessageAll( 'Toon HQ: All toons are being teleported to Loony Labs!') for doId in simbase.air.doId2do: if str(doId)[:2] == '10': player = simbase.air.doId2do.get(doId) player.magicTeleportInitiate(doId, 19000, 19000) taskMgr.doMethodLater(6, self.air.betaEventBDHQ.setState('StartBd'))
def __decButtonDown(self, event): assert self.notify.debugStateCall(self) task = Task(self.__repeatStepTask) task.stepSize = -self['stepSize'] taskName = self.taskName('repeatStep') #print 'decButtonDown: adding ', taskName taskMgr.doMethodLater(self['repeatStartdelay'], task, taskName) self.doStep(task.stepSize) messenger.send('wakeup') if self.__decButtonCallback: self.__decButtonCallback()
def endSession(self): self.stopHeartbeat = True self.stopSendingMovement = True self.endSession = EndSessionConnectionModel(self.exit) self.ServerConnection.setupConnectionModel(self.endSession) if not self.bypassServer: self.endSession.sendMessage(self.Character.actor.getPos(),self.Character.actor.getH()) #Forces an exit taskMgr.doMethodLater(3,self.exit,"forceExit")
def setDeferInterval(self, deferInterval): """Specifies the minimum amount of time, in seconds, that must elapse before generating any two DistributedObjects whose class type is marked "deferrable". Set this to 0 to indicate no deferring will occur.""" self.deferInterval = deferInterval self.setHandleCUpdates(self.deferInterval == 0) if self.deferredGenerates: taskMgr.remove('deferredGenerate') taskMgr.doMethodLater(self.deferInterval, self.doDeferredGenerate, 'deferredGenerate')
def _scheduleNextLeakCheck(self): taskMgr.doMethodLater(self._nextCheckDelay, self._checkForLeaks, self._getCheckTaskName()) # delay between checks # fib: 1 1 2 3 5 8 13 21 34 55 89 # * 2.: 1 2 4 8 16 32 64 128 256 512 1024 # * 1.5: 1 1.5 2.3 3.4 5.1 7.6 11.4 17.1 25.6 38.4 57.7 # # delay from job start # fib: 1 2 4 7 12 20 33 54 88 143 232 # * 2.: 1 3 7 15 31 63 127 255 511 1023 2047 # * 1.5: 1 2.5 4.75 8.1 13.2 20.8 32.2 49.3 74.9 113.3 171 self._nextCheckDelay = self._nextCheckDelay * self._checkDelayScale
def __init__(self): ShowBase.__init__(self) ShowBase.set_background_color(self, 0.08, 0.08, 0.08, 1) render.setAntialias(AntialiasAttrib.MAuto) self.disableMouse() self.messager = Messager() # tasks taskMgr.add(self.messager.check_for_new_players, "Poll the connection listener", -39) taskMgr.add(self.messager.check_for_message, "Poll the connection reader", -40) taskMgr.doMethodLater(HEARTBEAT_SERVER, self.messager.check_heartbeats, "Poll connection heartbeats")
def startJumpDelay(self, delay): assert self.notify.debugStateCall(self) if self.jumpDelayTask: self.jumpDelayTask.remove() self.mayJump = 0 self.jumpDelayTask = taskMgr.doMethodLater(delay, self.setMayJump, "jumpDelay-%s" % id(self))
def start(self): """ Start sending repeat events. """ if not self.task: self.task = taskMgr.doMethodLater(self.time, self.repeat, self.get_event())
def leakContainer(task=None): base = getBase() if not hasattr(base, 'leakContainer'): base.leakContainer = {} # use tuples as keys since they can't be weakref'd, and use an instance # since it can't be repr/eval'd # that will force the leak detector to hold a normal 'non-weak' reference class LeakKey: pass base.leakContainer[(LeakKey(),)] = {} # test the non-weakref object reference handling if random.random() < .01: key = random.choice(list(base.leakContainer.keys())) ContainerLeakDetector.notify.debug( 'removing reference to leakContainer key %s so it will be garbage-collected' % safeRepr(key)) del base.leakContainer[key] taskMgr.doMethodLater(10, leakContainer, 'leakContainer-%s' % serialNum()) if task: return task.done
def __init__(self, messager): Notifier.__init__(self, "ui-single-game") self.messager = messager taskMgr.doMethodLater(1, self.update_info, "UpdateSingleGameInfo") self.gid = None self.txts = [] self.txt_gid = OnscreenText(text="", pos=(1, .8), scale=0.1, fg=(1, 1, 1, 1)) self.txt_day = OnscreenText(text="", pos=(1, .7), scale=0.08, fg=(1, 1, 1, 1)) self.txt_red_room = OnscreenText(text="", pos=(1, .6), scale=0.08, fg=(0.68, 0.12, 0.12, 1)) self.txts.append(self.txt_gid) self.txts.append(self.txt_day) self.txts.append(self.txt_red_room) self.notify.info("[__init__] Created SingleGame")
def showMode(self, modeText): def hideText(state, s=self): s.readout.setText('') return Task.done taskMgr.remove(self.name + '-showMode') # Update display self.readout.setText(modeText) t = taskMgr.doMethodLater(3.0, hideText, self.name + '-showMode') t.setUponDeath(hideText)
def enterStateN(self, stateIndex, nextStateIndex): assert self.__debugPrint( "enterStateN(stateIndex=%s, nextStateIndex=%s)" % (stateIndex, nextStateIndex)) self.stateIndex = stateIndex self.nextStateIndex = nextStateIndex self.distributeStateChange() if self.durations[stateIndex] is not None: assert self.doLaterTask is None self.doLaterTask = taskMgr.doMethodLater( self.durations[stateIndex], self.switchToNextStateTask, "enterStateN-timer-%s" % id(self))
def connect(self): port_address = SERVER_PORT ip_address = SERVER_IP timeout = 3000 my_connection = self.cManager.openTCPClientConnection( ip_address, port_address, timeout) if my_connection: self.notify.info("Connected") self.father.set_connection(my_connection) self.cReader.addConnection(my_connection) # tasks taskMgr.add(self.messager.check_for_message, "Poll the connection reader", -39) taskMgr.doMethodLater(HEARTBEAT_PLAYER, self.messager.heartbeat, "Send heartbeat") else: Alert(-2) self.father.failed_to_connect() self.notify.warning("Could not connect!")
def startPosHprBroadcast(self, period=.2, stagger=0, type=None): if self.cnode is None: self.initializeCnode() BT = DistributedSmoothNodeBase.BroadcastTypes if type is None: type = BT.FULL # set the broadcast type self.broadcastType = type broadcastFuncs = { BT.FULL: self.cnode.broadcastPosHprFull, BT.XYH: self.cnode.broadcastPosHprXyh, BT.XY: self.cnode.broadcastPosHprXy, } # this comment is here so it will show up in a grep for 'def d_broadcastPosHpr' self.d_broadcastPosHpr = broadcastFuncs[self.broadcastType] # Set stagger to non-zero to randomly delay the initial task execution # over 'period' seconds, to spread out task processing over time # when a large number of SmoothNodes are created simultaneously. taskName = self.getPosHprBroadcastTaskName() # Set up telemetry optimization variables self.cnode.initialize(self, self.dclass, self.doId) self.setPosHprBroadcastPeriod(period) # Broadcast our initial position self.b_clearSmoothing() self.cnode.sendEverything() # remove any old tasks taskMgr.remove(taskName) # spawn the new task delay = 0. if stagger: delay = randFloat(period) if self.wantSmoothPosBroadcastTask(): taskMgr.doMethodLater(self.__broadcastPeriod + delay, self._posHprBroadcast, taskName)
def doShoot(self): pFrom = Point3(0,0,0) pTo = Point3() print "omega" omega = self.actorNP.getHpr().getX() print omega omega = (omega - 90)%360 v = Point3(math.cos(omega * math.pi / 180), math.sin(omega * math.pi / 180),0) v.normalize() v *= BULLETSPEED print '子弹速度 %s' %v #create Bullet size = Vec3(7,7,7) pFrom = self.actorNP.getPos() print '玩家位置 %s' %pFrom x = self.actorNP.getPos().getX() y = self.actorNP.getPos().getY() z = self.actorNP.getPos().getZ() hpr = self.actorNP.getHpr() print '玩家位置x %s' % x print '玩家位置y %s' % y print '玩家位置z %s' % z print '玩家方向hpr %s' % hpr print '胶囊包围体r %s' % self.actor_character_NP.getShape().getRadius() cosOmg = 10*math.cos(omega*math.pi/180) sinOmg = 10*math.sin(omega*math.pi/180) bulletNP = self.create_box_rigid('Bullet',size,Point3(x+cosOmg,y+sinOmg,10),True) bulletNP.node().setLinearVelocity(v) self.world.attachRigidBody(bulletNP.node()) bulletNP.setCollideMask(BitMask32.allOff()) print '子弹方向hpr %s' % v print '子弹位置 %s' %bulletNP.getPos() # Remove the bullet again after 1 sec taskMgr.doMethodLater(1,self.doRemove,'doRemove', extraArgs=[bulletNP], appendTask=True)
def __init__(self, the_dict, max_per_page, pos, scale=(0.1, 0.1, 0.1), frame_size=(-2, 2, -0.75, 0.75), command=None, active=True): """ @param the_dict: The dictionary to create a list of @type the_dict: dict @param max_per_page: Maximum number of items per page @type max_per_page: int @param pos: The position that you want the buttons to appear @type pos: tuple @param scale: The scale of the buttons @type scale: tuple @param frame_size: The size of the buttons @type frame_size: tuple @param command: The command to run if a command is desired. If none is inputted, it'll make OnscreenTexts rather than DirectButton @type command: function @param active: Should the list be displayed? @type active: bool """ taskMgr.doMethodLater(1, self.update_list, "Update the list") self.active = active self.page = 1 self.max_per_page = max_per_page self.frame_size = frame_size self.scale = scale self.pos = pos self.command = command self.btn_title = None self.the_dict = the_dict self.btns = []
def startCheckingIncomingHTTP(self, interval=0.3): taskMgr.remove('pollHTTPTask') taskMgr.doMethodLater(interval,self.pollHTTPTask,'pollHTTPTask')
new_arm_tcp_rotmat = rel_rotmat.dot(current_arm_tcp_rotmat) last_jnt_values = rbt_s.get_jnt_values() new_jnt_values = rbt_s.ik(tgt_pos=new_arm_tcp_pos, tgt_rotmat=new_arm_tcp_rotmat, seed_jnt_values=current_jnt_values) # if new_jnt_values is None: # continue rbt_s.fk(jnt_values=new_jnt_values) toc = time.time() start_frame_id = math.ceil((toc - tic) / .01) # rbt_x.arm_move_jspace_path([last_jnt_values, new_jnt_values], time_interval=.1, start_frame_id=start_frame_id) onscreen.append(rbt_s.gen_meshmodel()) onscreen[-1].attach_to(base) # print(pre_pos) # print(onscreen) operation_count += 1 # time.sleep(1/30) return task.cont if __name__ == '__main__': gm.gen_frame(length=3, thickness=0.01).attach_to(base) # threading.Thread(target=agv_move, args=()).start() taskMgr.doMethodLater(1 / 60, agv_move, "agv_move", extraArgs=None, appendTask=True) base.run()
def __init__(self, gsg=None, limit=None): DirectObject.__init__(self) # First, we'll need a name to uniquify the object. self.name = 'tex-mem%s' % (TexMemWatcher.NextIndex) TexMemWatcher.NextIndex += 1 self.cleanedUp = False self.top = 1.0 # The textures managed by the TexMemWatcher are packed # arbitrarily into the canvas, which is the viewable region # that represents texture memory allocation. The packing # arrangement has no relation to actual layout within texture # memory (which we have no way to determine). # The visual size of each texture is chosen in proportion to # the total number of bytes of texture memory the texture # consumes. This includes mipmaps, and accounts for texture # compression. Visually, a texture with mipmaps will be # represented by a rectangle 33% larger than an # equivalent-sized texture without mipmaps. Of course, this # once again has little bearing to the way the textures are # actually arranged in memory; but it serves to give a visual # indication of how much texture memory each texture consumes. # There is an arbitrary limit, self.limit, which may have been # passed to the constructor, or which may be arbitrarily # determined. This represents the intended limit to texture # memory utilization. We (generously) assume that the # graphics card will implement a perfect texture packing # algorithm, so that as long as our total utilization <= # self.limit, it must fit within texture memory. We represent # this visually by aggressively packing textures within the # self.limit block so that they are guaranteed to fit, as long # as we do not exceed the total utilization. This may # sometimes mean distorting a texture block or even breaking # it into multiple pieces to get it to fit, clearly # fictionalizing whatever the graphics driver is actually # doing. # Internally, textures are packed into an integer grid of # Q-units. Q-units are in proportion to texture bytes. # Specifically, each Q-unit corresponds to a block of # self.quantize * self.quantize texture bytes in the Texture # Memory window. The Q-units are the smallest packable unit; # increasing self.quantize therefore reduces the visual # packing resolution correspondingly. Q-units very roughly # correspond to pixels onscreen (they may be larger, sometimes # considerably larger, than 1 pixel, depending on the window # size). # This number defines the size of a Q-unit square, in texture # bytes. It is automatically adjusted in repack() based on # the window size and the texture memory size. self.quantize = 1 # This is the maximum number of bitmask rows (within # self.limit) to allocate for packing. This controls the # value assigned to self.quantize in repack(). self.maxHeight = base.config.GetInt('tex-mem-max-height', 300) # The total number of texture bytes tracked, including overflow. self.totalSize = 0 # The total number of texture bytes placed, not including # overflow (that is, within self.limit). self.placedSize = 0 # The total number of Q-units placed, not including overflow. self.placedQSize = 0 # If no GSG is specified, use the main GSG. if gsg is None: gsg = base.win.getGsg() elif isinstance(gsg, GraphicsOutput): # If we were passed a window, use that window's GSG. gsg = gsg.getGsg() self.gsg = gsg # Now open a new window just to render the output. size = ConfigVariableInt('tex-mem-win-size', '300 300') origin = ConfigVariableInt('tex-mem-win-origin', '100 100') self.winSize = (size[0], size[1]) name = 'Texture Memory' props = WindowProperties() props.setOrigin(origin[0], origin[1]) props.setSize(*self.winSize) props.setTitle(name) props.setFullscreen(False) props.setUndecorated(False) fbprops = FrameBufferProperties.getDefault() flags = GraphicsPipe.BFFbPropsOptional | GraphicsPipe.BFRequireWindow self.pipe = None # Set this to tinydisplay if you're running on a machine with # limited texture memory. That way you won't compete for # texture memory with the main scene. moduleName = base.config.GetString('tex-mem-pipe', '') if moduleName: self.pipe = base.makeModulePipe(moduleName) # If the requested pipe fails for some reason, we'll use the # regular pipe. if not self.pipe: self.pipe = base.pipe self.win = base.graphicsEngine.makeOutput(self.pipe, name, 0, fbprops, props, flags) assert self.win # We should render at the end of the frame. self.win.setSort(10000) # We don't need to clear the color buffer, since we'll be # filling it with a texture. We also don't need to clear the # depth buffer, since we won't be using it. self.win.setClearColorActive(False) self.win.setClearDepthActive(False) eventName = '%s-window' % (self.name) self.win.setWindowEvent(eventName) self.accept(eventName, self.windowEvent) # Listen for this event so we can update appropriately, if # anyone changes the window's graphics memory limit, self.accept('graphics_memory_limit_changed', self.graphicsMemoryLimitChanged) # We'll need a mouse object to get mouse events. self.mouse = base.dataRoot.attachNewNode( MouseAndKeyboard(self.win, 0, '%s-mouse' % (self.name))) bt = ButtonThrower('%s-thrower' % (self.name)) self.mouse.attachNewNode(bt) bt.setPrefix('button-%s-' % (self.name)) self.accept('button-%s-mouse1' % (self.name), self.mouseClick) self.setupGui() self.setupCanvas() # Now start handling up the actual stuff in the scene. self.background = None self.nextTexRecordKey = 0 self.rollover = None self.isolate = None self.isolated = None self.needsRepack = False # How frequently should the texture memory window check for # state changes? updateInterval = base.config.GetDouble("tex-mem-update-interval", 0.5) self.task = taskMgr.doMethodLater(updateInterval, self.updateTextures, 'TexMemWatcher') self.setLimit(limit)
def waitForNextHeartBeat(self): taskMgr.doMethodLater(self.heartbeatInterval, self.sendHeartbeatTask, "heartBeat", taskChain='net')
def startTask(self): self.stopTask() taskMgr.doMethodLater(self.updateFreq, self.doUpdate, "timeMgrTask")
def __init__(self, tcpPort, serverAddress=None, udpPort=None, dcFileNames=None, threadedNet=None): if threadedNet is None: # Default value. threadedNet = ConfigVariableBool('threaded-net', False).value # Set up networking interfaces. numThreads = 0 if threadedNet: numThreads = 1 self.qcm = QueuedConnectionManager() self.qcl = QueuedConnectionListener(self.qcm, numThreads) self.qcr = QueuedConnectionReader(self.qcm, numThreads) self.cw = ConnectionWriter(self.qcm, numThreads) taskMgr.setupTaskChain('flushTask') if threadedNet: taskMgr.setupTaskChain('flushTask', numThreads=1, threadPriority=TPLow, frameSync=True) self.tcpRendezvous = self.qcm.openTCPServerRendezvous( serverAddress or '', tcpPort, 10) self.qcl.addConnection(self.tcpRendezvous) taskMgr.add(self.listenerPoll, "serverListenerPollTask") taskMgr.add(self.readerPollUntilEmpty, "serverReaderPollTask") taskMgr.add(self.clientHardDisconnectTask, "clientHardDisconnect") # A set of clients that have recently been written to and may # need to be flushed. self.needsFlush = set() collectTcpInterval = ConfigVariableDouble( 'collect-tcp-interval').getValue() taskMgr.doMethodLater(collectTcpInterval, self.flushTask, 'flushTask', taskChain='flushTask') # A dictionary of connection -> Client object, tracking all of # the clients we currently have connected. self.clientsByConnection = {} # A similar dictionary of doIdBase -> Client object, indexing # by the client's doIdBase number instead. self.clientsByDoIdBase = {} # A dictionary of zoneId -> set([Client]), listing the clients # that have an interest in each zoneId. self.zonesToClients = {} # A dictionary of zoneId -> set([Object]), listing the # distributed objects assigned to each zone, globally. self.objectsByZoneId = {} # The number of doId's to assign to each client. Must remain # constant during server lifetime. self.doIdRange = _server_doid_range.value # An allocator object that assigns the next doIdBase to each # client. self.idAllocator = UniqueIdAllocator(0, 0xffffffff // self.doIdRange) self.dcFile = DCFile() self.dcSuffix = '' self.readDCFile(dcFileNames)
def doUpdate(self, task): self.synchronize("timer") # Spawn the next one taskMgr.doMethodLater(self.updateFreq, self.doUpdate, "timeMgrTask") return Task.done
if rbtmnp[0] is not None: rbtmnp[0].detachNode() pose = path[motioncounter[0]] rbt.movearmfk(pose, armname) rbtmnp[0] = rbtmg.genmnp(rbt, 0, obj.height) pos = rbt.lftarm[-1]['linkend'] rot = rbt.lftarm[-1]['rotmat'] ee_w_t[:3, :3] = rot ee_w_t[:3, 3] = pos obj_w_t = np.dot(ee_w_t, obj_ee_t) objcm.setMat(pg.npToMat4(obj_w_t[:3, :3])) objcm.setPos(obj_w_t[0, 3], obj_w_t[1, 3], obj_w_t[2, 3]) objcm.reparentTo(base.render) rbtmnp[0].reparentTo(base.render) motioncounter[0] += 1 else: motioncounter[0] = 0 return task.again rbtmnp = [None] motioncounter = [0] taskMgr.doMethodLater( 0.1, update, "udpdate", extraArgs=[rbtmnp, motioncounter, rbt, path, "lft", rbtmg, objcm], appendTask=True) base.run()
def _leakNode(self, task=None): self._render.attachNewNode('leakNode-%s' % serialNum()) taskMgr.doMethodLater(10, self._leakNode, self._leakTaskName)
def doGameScreen(self): self.heartbeatConnection = HeartbeatConnectionModel() self.ServerConnection.setupConnectionModel(self.heartbeatConnection) self.accept("tab",self.CharacterListScreen.toggleScreen) self.stopHeartbeat = False self.stopSendingMovement = False self.backgroundImage.destroy() self.Character.setControls() self.Character.actor.setHpr(0,0,0) taskMgr.add(self.Character.move,"moveTask") self.inst = [] self.inst.append(addInstructions(0.95, "[ESC]: Quit/Close Chat Window")) self.inst.append(addInstructions(0.90, "[a]: Rotate Player Left")) self.inst.append(addInstructions(0.85, "[d]: Rotate Player Right")) self.inst.append(addInstructions(0.80, "[w]: Move Player Forward")) self.inst.append(addInstructions(0.75, "[s]: Move Player Backward")) self.inst.append(addInstructions(0.70, "[shift+w]: Move Player Fast")) self.inst.append(addInstructions(0.65, "[q]: Rotate Camera Left")) self.inst.append(addInstructions(0.60, "[e]: Rotate Camera Right")) self.inst.append(addInstructions(0.55, "[tab]: Show players")) if not self.bypassServer: self.inst.append(addInstructions(0.50, "[t]: Display Chat Window")) self.inst.append(addInstructions(0.45, "[p]: Display PM Window")) # Set up the environment self.environ = loader.loadModel("models/square") self.environ.reparentTo(render) self.environ.setPos(0,0,0) self.environ.setScale(100,100,1) self.moon_tex = loader.loadTexture("models/moon_1k_tex.jpg") self.environ.setTexture(self.moon_tex, 1) self.staticRefSun = StaticModelSun(self,render,base,loader) self.staticRefVenus = StaticModelVenus(self,render,base,loader) self.staticRefEarth = StaticModelEarth(self,render,base,loader) self.sun = self.staticRefSun.getSun() self.venus = self.staticRefVenus.getVenus() self.earth = self.staticRefEarth.getEarth() taskMgr.add(self.staticRefSun.rotateSun,"rotateSun") taskMgr.add(self.staticRefVenus.rotateVenus,"rotateVenus") taskMgr.add(self.staticRefEarth.rotateEarth,"rotateEarth") taskMgr.add(self.staticRefEarth.stopRotateEarth,"stopRotateEarth") taskMgr.add(self.staticRefSun.stopRotateSun,"stopRotateSun") taskMgr.add(self.staticRefVenus.stopRotateVenus,"stopRotateVenus") taskMgr.add(self.setToGround, "setToGround") if not self.bypassServer: taskMgr.doMethodLater(self.config['heartbeatRate'],self.doHeartbeat,"heartbeat") taskMgr.doMethodLater(self.config['sendMoveRate'],self.MoveManager.sendMoves,"movement") #Change Camera Position Later base.camera.setPos(self.Character.actor.getX(),self.Character.actor.getY()+10,2) # Create some lighting ambientLight = AmbientLight("ambientLight") ambientLight.setColor(Vec4(.3, .3, .3, 1)) directionalLight = DirectionalLight("directionalLight") directionalLight.setDirection(Vec3(-5, -5, -5)) directionalLight.setColor(Vec4(1, 1, 1, 1)) directionalLight.setSpecularColor(Vec4(1, 1, 1, 1)) render.setLight(render.attachNewNode(ambientLight)) render.setLight(render.attachNewNode(directionalLight)) if not self.bypassServer: self.chatScreen = ChatScreen(self,render,base) self.pChatScreen = PrivateChatScreen(self,render,base) self.chatScreen.hideScreen() self.pChatScreen.hideScreen()