def __init__(self, camera, parent):
        """Arguments:
        camera -- Camera to be used
        parent -- Aeroplane which the camera should follow
        """

        self.notifier = DirectNotify().newCategory("azure-camera")
        self.camera = camera
        self.parent = parent
        # This gets replaced by a NodePath with all available cameras as
        # children and plane node as parent in createCamNodes()
        self.cameras = None

        #if parent.__class__.__name__ is not "Aeroplane":
        if not isinstance(self.parent, Aeroplane):
            raise ParamError, "Parent must be an Aeroplane instance, " + \
                              "but is %s" % type(self.parent)

        FSM.__init__(self, "PlaneCamera: %s" % self.parent.name)
        DirectObject.__init__(self)

        self.cameras = self.parent.node.find("cameras")
        if self.cameras.isEmpty():
            self.createCamNodes()
        self.updateCamArray()

        self.sideview_direction = 0

        # Set up the default camera
        self.setView("ThirdPerson")
示例#2
0
 def __init__(self):
     DirectObject.__init__(self)
     self.base = ShowBase()
     resolution = (1024, 768)
     wp = WindowProperties()
     wp.setSize(int(resolution[0]), int(resolution[1]))
     wp.setOrigin(0, 0)
     self.base.win.requestProperties(wp)
     # depth completely doesn't matter for this, since just 2d, and no layers
     self.depth = 0
     self.base.setBackgroundColor(115 / 255, 115 / 255, 115 / 255)
     # set up a 2d camera
     camera = self.base.camList[0]
     lens = OrthographicLens()
     lens.setFilmSize(int(resolution[0]), int(resolution[1]))
     lens.setNearFar(-100, 100)
     camera.node().setLens(lens)
     camera.reparentTo(self.base.render)
     self.accept("escape", sys.exit)
     # spread out some positions
     self.positions = [(-200, 0, -200),
                       (0, 0, -200),
                       (200, 0, -200),
                       (-200, 0, 0),
                       (0, 0, 0),
                       (200, 0, 0),
                       (-200, 0, 200),
                       (0, 0, 200),
                       (200, 0, 200)]
     self.all_smiles()
示例#3
0
文件: Character.py 项目: denssle/WoWK
 def __init__(self):
   DirectObject.__init__(self)
   self.data = dict()
   for key in POLLKEYS:
     self.accept( key, self.event, [key, True] )
     self.accept( key+"-up", self.event, [key, False] )
     self.data[key] = False
示例#4
0
 def __init__(self, level, showBase): 
     DirectObject.__init__(self)
     self.showBase = showBase
     self.levelName = level
     mySound = base.loader.loadSfx("../resources/audio/Game Jam - Stefan Putzinger - Theme 02.wav")
     mySound.setVolume(0.5)
     mySound.play()
示例#5
0
    def __init__(self, *args, **kwargs):
        NodePath.__init__(self, *args, **kwargs)
        DirectObject.__init__(self)

        self.scale_signal = Signal()

        self.reset()
示例#6
0
    def __init__(self, name):
        FSM.__init__(self, name)
        PandaNode.__init__(self, name)
        DirectObject.__init__(self)

        self.active = True

        self.lastClickState = PGButton.SReady
        self.clickState = PGButton.SReady

        self.__hovering = False

        self.clickEvent = ''
        self.clickExtraArgs = []

        self.contents = NodePath.anyPath(self).attachNewNode('contents')

        # Create a MouseWatcherRegion:
        self.regionName = self.getUniqueName() + '-region'
        self.region = MouseWatcherRegion(self.regionName, 0, 0, 0, 0)
        base.mouseWatcherNode.addRegion(self.region)

        # Accept the mouse events:
        enterPattern = base.mouseWatcherNode.getEnterPattern()
        leavePattern = base.mouseWatcherNode.getLeavePattern()
        buttonDownPattern = base.mouseWatcherNode.getButtonDownPattern()
        buttonUpPattern = base.mouseWatcherNode.getButtonUpPattern()
        self.accept(enterPattern.replace('%r', self.regionName), self.__handleMouseEnter)
        self.accept(leavePattern.replace('%r', self.regionName), self.__handleMouseLeave)
        self.accept(buttonDownPattern.replace('%r', self.regionName), self.__handleMouseDown)
        self.accept(buttonUpPattern.replace('%r', self.regionName), self.__handleMouseUp)
示例#7
0
    def __init__(self):
        DirectFrame.__init__(self, relief=None, sortOrder=500)
        DirectObject.__init__(self)
        gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')

        self.log = DirectScrolledList(
            parent=self,
            decButton_pos=(0.45, 0, 0.65),
            decButton_image=(gui.find('**/FndsLst_ScrollUp'),
                             gui.find('**/FndsLst_ScrollDN'),
                             gui.find('**/FndsLst_ScrollUp_Rllvr'),
                             gui.find('**/FndsLst_ScrollUp')),
            decButton_relief=None,
            incButton_pos=(0.45, 0, -0.1475),
            incButton_image=(gui.find('**/FndsLst_ScrollUp'),
                             gui.find('**/FndsLst_ScrollDN'),
                             gui.find('**/FndsLst_ScrollUp_Rllvr'),
                             gui.find('**/FndsLst_ScrollUp')),
            incButton_relief=None,
            incButton_scale=(1.0, 1.0, -1.0),
            itemFrame_geom=(loader.loadModel("phase_3.5/models/gui/frame")),
            itemFrame_geom_scale=(.14, 1, .17),
            itemFrame_geom_pos=(0, 0, -.25),
            itemFrame_geom_color=(1, 1, 1, 0.6),
            itemFrame_relief=None,
            items=[],
            numItemsVisible=6,
            forceHeight=.1,
            itemFrame_frameSize=(-0.4, 0.5, -0.4, 0.16),
            itemFrame_pos=(0.45, 0, 0.5),
        )
        self.isHidden = True

        base.cr.chatLog = self
示例#8
0
 def __init__(self, model: MainSectionModel):
     DirectObject.__init__(self)
     self.model = model
     self.chat_bubbles_by_names = {}
     self.seconds_per_bubble = 5  # seconds
     self.accept(Event.MSG_RECEIVED, self.handle_msg_received)
     self.accept(Event.UNIT_DISCONNECTED, self.handle_unit_disconnected)
示例#9
0
 def __init__(self,
              parent_node,
              color=(0, 0, 0, 1),
              width=0.5,
              height=0.5,
              x=0,
              y=0,
              image=None,
              hpr=(0, 0, 0),
              image_hpr=(0, 0, 0),
              text=""):
     DirectObject.__init__(self)
     self.node = parent_node.attach_new_node(f"frame {self}")
     self.text_x_offset = 0.004
     self.text_y_offset = 0.016
     self.text_scale = 0.01
     self.frame = DirectFrame(
         hpr=hpr,
         parent=self.node,
         frameColor=color,
         frameTexture=image,
         image_hpr=image_hpr,
         text=text,
         text_roll=180,
         text_scale=20,
         text_font=MainFont(),
         text_fg=(1, 1, 1, 1),
     )
     self.x = x
     self.y = y
     self.width = width
     self.height = height
     self.accept("aspectRatioChanged", self.aspect_ratio_change_update)
示例#10
0
    def __init__(self, base, r, theta, phi):
        DirectObject.__init__(self)
        self.base = base

        # Parameters
        self.rotateMag = 0.5
        self.moveMag = 50
        self.zoomMag = 100

        # Camera properties
        self.r = r
        self.theta = theta
        self.phi = phi
        self.target = NodePath("target")
        self.target.reparentTo(self.base.render)
        self.base.camera.reparentTo(self.target)
        self.followingObject = None

        # Controls
        self.mouseDown1 = False
        self.mouseDown2 = False
        self.mouseDown3 = False
        self.mousePrevX = 0.0
        self.mousePrevY = 0.0
        self.accept("mouse1", self.onMouse1, [True])
        self.accept("mouse1-up", self.onMouse1, [False])
        self.accept("mouse2", self.onMouse2, [True])
        self.accept("mouse2-up", self.onMouse2, [False])
        self.accept("mouse3", self.onMouse3, [True])
        self.accept("mouse3-up", self.onMouse3, [False])

        # Run task that updates camera
        self.base.taskMgr.add(self.updateCamera, "UpdateCameraTask", priority=1)
示例#11
0
 def __init__(self, cline):
     # DiOb init
     DirectObject.__init__(self)
     # Stash the relavant stuff from the GUI
     self.cline = cline
     self.stack = []
     # What are we doing, after all?
     self.commands = {
         "r": ("Build Room", {
             "c": ("Corridor", self.build_corridor),
             "b": ("Baggage Area", self.build_corridor),
             "t": ("Toilets", self.build_corridor),
         }),
         "b": ("Build Item", {
             "r": ("Runway", {
                 "1": ("1km Runway", self.build_corridor),
                 "2": ("2km Runway", self.build_corridor),
             }),
             "b": ("Baggage Area", self.build_corridor),
             "t": ("Toilets", self.build_corridor),
         }),
     }
     # Attach to a lot of signals
     for char in "brtc12":
         self.accept(char, (lambda char: lambda: self.letter_down(char))(char)) # Python scope fix.
示例#12
0
    def __init__(self, taskMgr, base):
        DirectObject.__init__(self)
        self.taskMgr = taskMgr
        self.base = base
        self.setupPoint2d()

        self.beastPointSize = ConfigVariableDouble('beast-point-size',
                                                   1.0).getValue()
        self.beastPointSizeAuto = ConfigVariableBool('beast-point-size-auto',
                                                     False).getValue()
        self.beastRenderBruteForce = ConfigVariableBool(
            'beast-render-brute-force', False).getValue()
        self.beastRenderDebug = ConfigVariableBool('beast-render-debug',
                                                   False).getValue()

        self.setPointSize(self.beastPointSize, update=False)
        self.setPointSizeAuto(self.beastPointSizeAuto, update=False)
        self.accept('window-event', self.windowEvent)
        self.originalResolution = (float(self.base.win.getXSize()),
                                   float(self.base.win.getYSize()))

        self.buffer = None
        #- If bruteForce == False then we will setup beast frame rendering system
        if self.beastRenderBruteForce == False:
            self._setupTextureBuffer()
            taskMgr.add(self.renderTask, 'beastRender', sort=-100000000)

        self.windowEvent()
示例#13
0
 def __init__(self, doc):
     DirectObject.__init__(self)
     self.doc = doc
     self.historyIndex = -1
     self.savedIndex = -1
     self.stateChangeIndex = -1
     self.history = []
    def __init__(self):
        DirectObject.__init__(self)
        
        self.pathSmoothening = False
        self.showWaypoints = True
        self.showCollisions = False
        
        self.accept("escape", sys.exit)
        
        self.__setupEnvironment()
        self.__setupCollisions()
        self.__setupGravity()
        self.__setupLevel()
        self.__setupTarget()
        self.__setupNPC()
        self.__setupCamera()
        self.__setupTasks()
        
        self.setKeymap()
        self.__NPC.pathSmoothening = self.pathSmoothening

        if(self.showWaypoints):
            print("Showing waypoints")
            for w in self.roomWaypoints:
                w.draw()
示例#15
0
    def __init__(self, name):
        PandaNode.__init__(self, name)
        DirectObject.__init__(self)

        self.fsm = ClassicFSM(name, [
            State('off', self.enterOff, self.exitOff),
            State('rollover', self.enterRollover, self.exitRollover),
            State('ready', self.enterReady, self.exitReady),
            State('depressed', self.enterDepressed, self.exitDepressed),
            State('inactive', self.enterInactive, self.exitInactive)], 'off', 'off')
        self.fsm.enterInitialState()

        self.active = True
        self.lastClickState = PGButton.SReady
        self.clickState = PGButton.SReady
        self.__hovering = False
        self.clickEvent = ''
        self.clickExtraArgs = []
        self.contents = NodePath.anyPath(self).attachNewNode('contents')

        # Create a MouseWatcherRegion:
        self.regionName = self.getUniqueName() + '-region'
        self.region = MouseWatcherRegion(self.regionName, 0, 0, 0, 0)
        base.mouseWatcherNode.addRegion(self.region)

        # Accept the mouse events:
        enterPattern = base.mouseWatcherNode.getEnterPattern()
        leavePattern = base.mouseWatcherNode.getLeavePattern()
        buttonDownPattern = base.mouseWatcherNode.getButtonDownPattern()
        buttonUpPattern = base.mouseWatcherNode.getButtonUpPattern()
        self.accept(enterPattern.replace('%r', self.regionName), self.__handleMouseEnter)
        self.accept(leavePattern.replace('%r', self.regionName), self.__handleMouseLeave)
        self.accept(buttonDownPattern.replace('%r', self.regionName), self.__handleMouseDown)
        self.accept(buttonUpPattern.replace('%r', self.regionName), self.__handleMouseUp)
示例#16
0
    def __init__(self, name, dynamic=False):
        NodePath.__init__(self, PGTop(name))
        DirectObject.__init__(self)
        self.setPythonTag('SpriteCollection', self)

        global SpriteCollectionCounter
        SpriteCollectionCounter += 1
        self.__id = int(SpriteCollectionCounter)

        self.node().setMouseWatcher(base.mouseWatcherNode)
        self.setDepthTest(False)
        self.setDepthWrite(False)
        self.setMaterialOff(True)
        self.setTwoSided(True)

        self.__lastRender = globalClock.getFrameCount()
        self.buffer = None
        self.__dynamic = dynamic
        self.__beastRenderCache = ConfigVariableBool('beast-render-cache',
                                                     True).getValue()
        self.__beastForceNewFrame = ConfigVariableBool('beast-force-new-frame',
                                                       True).getValue()
        self.__beastDebug = ConfigVariableBool('beast-debug', False).getValue()
        if self.__dynamic == False and self.__beastRenderCache == True:
            self.fakeRender2d = NodePath('fakeRender2d-%s-%s' %
                                         (self.__id, self.getName()))
            self.reparentTo(self.fakeRender2d)

            self._setupTextureBuffer()
            self.accept('beastCollectionUpdate', self._update)
            base.taskMgr.add(self._update,
                             'updateTask-%s-%s' % (self.__id, self.getName()),
                             sort=-1000)
        else:
            self.reparentTo(render2d)
示例#17
0
    def __init__(self,
                 interestMgr,
                 name,
                 doneEvent=None,
                 recurse=True,
                 start=True,
                 mustCollect=False,
                 doCollectionMgr=None):
        DirectObject.__init__(self)

        self._interestMgr = interestMgr

        if doCollectionMgr is None:
            doCollectionMgr = interestMgr

        self._doCollectionMgr = doCollectionMgr

        self._eGroup = EventGroup(name, doneEvent=doneEvent)

        self._doneEvent = self._eGroup.getDoneEvent()

        self._gotEvent = False

        self._recurse = recurse

        if self._recurse:
            # this will hold a dict of parentId to set(zoneIds) that are closing
            self.closingParent2zones = {}

        if start:
            self.startCollect(mustCollect)
示例#18
0
 def __init__(self, air):
     DirectObject.__init__(self)
     self.air = air
     self.currentHolidays = []
     self.xpMultiplier = 3  # for the rest of alpha if 5x isnt enabled
     self.setup()
     self.checkForHoliday('checkForHoliday')
示例#19
0
 def __init__( self ):
     DirectObject.__init__( self )
     self.keyMap = {}
     self.initKeys()
     self.baseNode = None
     self.watchNode = None
     self.rotating = False
    def __init__(self, url):
        DirectObject.__init__(self)

        self.url = URLSpec(url)
        self.image = None

        # Create a condition variable so we can block on load.
        self.cvar = threading.Condition()
        self.done = False

        # Create an initial 1x1 white texture.
        self.tex = Texture(Filename(self.url.getPath()).getBasename())
        p = PNMImage(1, 1)
        p.fill(0.5, 0.5, 1)
        self.tex.load(p)

        if self.url.getScheme() == 'maze':
            # Here's a special case: instead of querying an HTTP
            # server, we get the local poster data from the maze
            # object.
            self.loadPlayerPoster()

        elif self.url.getScheme() == '':
            # Another special case: this is a local file.  This should
            # only happen from the local player.
            self.loadLocalPoster()

        else:
            # Otherwise, we get the poster data from the internet.
            self.loadingTask = taskMgr.add(self.load,
                                           'loadPoster',
                                           taskChain='loadPoster')
示例#21
0
    def __init__(self, base, r, theta, phi):
        DirectObject.__init__(self)

        # Camera properties
        self.base = base
        self.r = r
        self.theta = theta
        self.phi = phi
        self.position = Point3(0.0, 0.0, 0.0)
        self.offset = Vec3(0.0, 0.0, 0.0)
        self.target = Point3(0.0, 0.0, 0.0)

        # Controls
        self.mouseDown1 = False
        self.mouseDown2 = False
        self.mouseDown3 = False
        self.mousePrevX = 0.0
        self.mousePrevY = 0.0
        self.accept("mouse1", self.onMouse1, [True])
        self.accept("mouse1-up", self.onMouse1, [False])
        self.accept("mouse2", self.onMouse2, [True])
        self.accept("mouse2-up", self.onMouse2, [False])
        self.accept("mouse3", self.onMouse3, [True])
        self.accept("mouse3-up", self.onMouse3, [False])
        base.taskMgr.add(self.updateCamera, "UpdateCameraTask")
示例#22
0
 def __init__(self, placeholder, pos, on_enter, focus=False, sort_order=0):
     """
     Object of a simple entry field
     @param placeholder: text to appear in textbox automatically
     @type placeholder: string
     @param pos: where to place the textbox
     @type pos: (float, float, float)
     @param on_enter: function to call upon them submitting a response
     @type on_enter: function
     @param focus: Should the entry auto-focus?
     @type focus: bool
     @param sort_order: Where should Entry display? (Alert is at 1000)
     @type sort_order: int
     """
     DirectObject.__init__(self)
     self.accept('mouse1', self.click_out)
     self.placeholder = placeholder
     self.on_enter = on_enter
     self.entry = DirectEntry(initialText=self.placeholder,
                              scale=0.05,
                              focus=focus,
                              focusOutCommand=self.focus_out,
                              focusInCommand=self.focus_in,
                              pos=pos,
                              sortOrder=sort_order)
示例#23
0
文件: screen.py 项目: onze/goLive
 def __init__(self):
    DirectObject.__init__(self)
    self.close=lambda:None
    #create main window
    base=ShowBase()
    __builtin__.base=base
    props = WindowProperties()
    #props.setTitle(ConfigVariableString('win-title').getValue()) 
    props.setFullscreen(ConfigVariableBool('fullscreen').getValue())
    props.setSize(ConfigVariableInt('win-width').getValue(),ConfigVariableInt('win-height').getValue())
    base.win.requestProperties(props)
    self.width=base.win.getXSize() 
    self.height=base.win.getYSize()
    print 'size=',self.width,'x',self.height
    self.accept('window-event',self.on_resize)
    base.disableMouse()
    #set fps limit
    globalClock=ClockObject.getGlobalClock() 
    globalClock.setMode(ClockObject.MLimited) 
    globalClock.setFrameRate(ConfigVariableDouble('clock-frame-rate').getValue())
    __builtin__.screen=self
    __builtin__.gui=pixel2d.attachNewNode('Screen.gui')
    #gui is the node for 2d rendering, scaled to the screen resolution,
    #with origin at bottom-left, and max at top-right
    gui.setZ(gui,-self.height)
    __builtin__.console=Console(print_messenger_events=False)
    __builtin__.out=console.out
    console.request('Open')
    __builtin__.mouse=base.pointerWatcherNodes[0]
    #is used as a stack. stores frames showed to the user (top at the front of the screen)
    self.frames=[]
示例#24
0
    def __init__(self, main):
        DirectObject.__init__(self)

        self.showbase = main

        self.background = DirectFrame(
            frameSize=(-1, 1, -1, 1),
            frameTexture='media/gui/login/bg.png',
            parent=self.showbase.render2d,
        )

        self.username = "******"
        self.server = "localhost"

        self.loginScreen("Press 'Enter' to login")
        # draws the login screen

        self.usernameBox['focus'] = 1
        # sets the cursor to the username field by default

        self.accept('tab', self.cycleLoginBox)
        self.accept('shift-tab', self.cycleLoginBox)
        # enables the user to cycle through the text fields with the tab key
        # this is a standard feature on most login forms

        self.accept('enter', self.attemptConnect)
        # submits the login form, or you can just click the Login button

        # checking variable to stop multiple presses of the button spawn multiple tasks
        self.requestAttempt = False

        self.updateStatus("Type Server and Connect!")
 def __init__(self, name, worldNode, mapGeom):
     DirectObject.__init__(self)
     self.map = None
     self.worldNode = worldNode
     self.mapNode = NodePath(name)
     self.mapGeom = mapGeom.copyTo(self.mapNode)
     self.overlayNode = NodePath(name)
示例#26
0
    def __init__(self):
        DirectObject.__init__(self)
        base.setBackgroundColor(0,0,0,1)

        self.gameStarted = 0
        self.gamePaused = 0
        self.timeLeft = 100
        self.speed = 2
        self.obstacle_count = 10

        self.keyMap = {"left":0, "right":0, "forward":0, "backward":0, "cam-left":0, "cam-right":0}
        self.musicDir = {"intro":"", "playing_game":"", "game_over":""}
        self.acceptOnce('f1', self.startGame)
        self.accept("escape", sys.exit)
        self.accept("arrow_left", self.setKey, ["cam-left",1])
        self.accept("arrow_right", self.setKey, ["cam-right",1])
        self.accept("w", self.setKey, ["forward",1])
        self.accept("a", self.setKey, ["left",1])
        self.accept("s", self.setKey, ["backward", 1])
        self.accept("d", self.setKey, ["right",1])
        self.accept("arrow_left-up", self.setKey, ["cam-left",0])
        self.accept("arrow_right-up", self.setKey, ["cam-right",0])
        self.accept("w-up", self.setKey, ["forward",0])
        self.accept("a-up", self.setKey, ["left",0])
        self.accept("s-up", self.setKey, ["backward", 0])
        self.accept("d-up", self.setKey, ["right",0])
        
        # Songs
        self.loadSongs()
        self.showIntroPage()
 def __init__(self, name, radius = 1, scrollFactor = 1, camera = base.cam, frame = Vec4(-1, 1, -1, 1), keepUpright = 0, mouseDownEvent = 'mouse1', mouseUpEvent = 'mouse1-up', *args, **kwargs):
     NodePath.__init__(self, name, *args, **kwargs)
     DirectObject.__init__(self)
     self._rNode = self.attachNewNode('rotateNode')
     self._setRadius(radius, False)
     self._setScrollFactor(scrollFactor, False)
     self._setCamera(camera, False)
     self._setFrame(frame, False)
     self._setKeepUpright(keepUpright)
     self._setMouseEvents(mouseDownEvent, mouseUpEvent)
     self.setRotateMode(0)
     self._setControlButtonState(0)
     self._setTiltLimit(25 * math.pi / 180, False)
     self.saveNorth()
     self._colBitMask = BitMask32(1 << 16)
     self._colNode = self.attachNewNode(CollisionNode(name + '-cNode'))
     self._colNode.node().addSolid(CollisionSphere(0, 0, 0, 1))
     self._colNode.node().setIntoCollideMask(self._colBitMask)
     self._mouseEnabled = True
     self._initCollisions()
     self.geom_node_path = self.attachNewNode('arrow')
     self.geom_node_path.setBin('fixed', 100)
     self.geom_node_path.setDepthTest(0)
     self.geom_node_path.setTransparency(1)
     self.head_geom_node = GeomNode('head')
     self.head_geom_node_path = self.geom_node_path.attachNewNode(self.head_geom_node)
     self.tail_geom_node = GeomNode('tail')
     self.tail_geom_node_path = self.geom_node_path.attachNewNode(self.tail_geom_node)
     self._ballIval = None
示例#28
0
    def __init__(self, base, r, theta, phi):
        DirectObject.__init__(self)
        self.base = base

        # Parameters
        self.rotateMag = 0.5
        self.moveMag = 50
        self.zoomMag = 15

        # Camera properties
        self.r = r
        self.theta = theta
        self.phi = phi

        self.target = NodePath("target")
        self.target.reparentTo(self.base.render)
        self.base.camera.reparentTo(self.target)

        # Controls
        self.mouseDown1 = False
        self.mouseDown2 = False
        self.mouseDown3 = False
        self.mousePrevX = 0.0
        self.mousePrevY = 0.0

        self.updateCamera(0, 0)
 def __init__(
     self,
     name,
     size=Vec2(512, 512) * 2.0,
     camAspectRatio=1.0,
     clearColor=Vec4(0.84999999999999998, 0.84999999999999998, 0.84999999999999998, 1.0),
     sceneGraph=None,
 ):
     DirectObject.__init__(self)
     self.name = name
     self.size = size
     if not sceneGraph:
         self._SceneBuffer__sceneGraph = NodePath(self.name + "-render")
     else:
         self._SceneBuffer__sceneGraph = sceneGraph
     self.camera = self._SceneBuffer__sceneGraph.attachNewNode(Camera(self.name + "camera"))
     self.camNode = self.camera.node()
     self.camLens = PerspectiveLens()
     self.camLens.setFov(30, 30)
     self.camNode.setLens(self.camLens)
     self._SceneBuffer__texture = Texture(self.name)
     self._SceneBuffer__buffer = None
     self._SceneBuffer__createBuffer()
     self.accept("close_main_window", self._SceneBuffer__destroyBuffer)
     self.accept("open_main_window", self._SceneBuffer__createBuffer)
示例#30
0
 def __init__(self, cr = None):
     DirectObject.__init__(self)
     self.cr = cr
     self.centralHood = TTCHood(self.cr)
     self.homeHood = HomeHood()
     self.minigameHood = MinigameHood(self.cr)
     self.progressScreen = ToontownProgressScreen()
示例#31
0
    def __init__(self):
        __metaclass__ = ABCMeta
        DirectObject.__init__(self)
        BaseAttack.__init__(self)
        self.avatar = None
        self.gag = None
        self.target = None
        self.splat = None
        self.splatPos = None
        self.state = GagState.LOADED
        self.woosh = None
        self.handJoint = None
        self.equipped = False
        self.index = None
        self.id = GagGlobals.getIDByName(self.name)
        self.timeout = 5
        self.animTrack = None
        self.holdGag = True

        # Handles the new recharging for certain gags.

        # The time it takes (in seconds) to recharge this gag.
        self.rechargeTime = 0

        # The elapsed time of the current recharge. Should be a float
        self.rechargeElapsedTime = 0

        if metadata.PROCESS == 'client':
            if self.gagType == GagType.THROW:
                self.woosh = base.audio3d.loadSfx(GagGlobals.PIE_WOOSH_SFX)
            self.hitSfx = base.audio3d.loadSfx(self.hitSfxPath)
            self.drawSfx = base.audio3d.loadSfx(GagGlobals.DEFAULT_DRAW_SFX)
示例#32
0
文件: Arena.py 项目: warycat/Debugger
 def __init__(self):
     DirectObject.__init__(self)
     base.disableMouse()
     self.default()
     self.accept('1',self.front)
     self.accept('2',self.top)
     self.accept('0',self.default)
示例#33
0
 def __init__( self, *args, **kwargs ):
     DirectObject.__init__( self )
     
     # Default camera to base camera if None is specified
     self.camera = kwargs.pop( 'camera', base.camera )
         
     # Default root node to render if None is specified
     self.rootNp = kwargs.pop( 'rootNp', render )
         
     # Default root 2d node to render2d if None is specified
     self.root2d = kwargs.pop( 'root2d', render2d )
         
     # Default root aspect 2d node to aspect2d if None is specified
     self.rootA2d = kwargs.pop( 'rootA2d', aspect2d )
         
     # Default root pixel 2d node to pixel2d if None is specified
     self.rootP2d = kwargs.pop( 'rootP2d', pixel2d )
         
     # Default win to base.win if None specified.
     self.win = kwargs.pop( 'win', base.win )
     
     # Default mouse watcher node to base.win if None specified.
     self.mouseWatcherNode = kwargs.pop( 'mouseWatcherNode', 
                                         base.mouseWatcherNode )
     
     
示例#34
0
 def __init__(self,
              name,
              size=Vec2(512, 512) * 2.0,
              camAspectRatio=1.0,
              clearColor=Vec4(0.84999999999999998, 0.84999999999999998,
                              0.84999999999999998, 1.0),
              sceneGraph=None):
     DirectObject.__init__(self)
     self.name = name
     self.size = size
     if not sceneGraph:
         self._SceneBuffer__sceneGraph = NodePath(self.name + '-render')
     else:
         self._SceneBuffer__sceneGraph = sceneGraph
     self.camera = self._SceneBuffer__sceneGraph.attachNewNode(
         Camera(self.name + 'camera'))
     self.camNode = self.camera.node()
     self.camLens = PerspectiveLens()
     self.camLens.setFov(30, 30)
     self.camNode.setLens(self.camLens)
     self._SceneBuffer__texture = Texture(self.name)
     self._SceneBuffer__buffer = None
     self._SceneBuffer__createBuffer()
     self.accept('close_main_window', self._SceneBuffer__destroyBuffer)
     self.accept('open_main_window', self._SceneBuffer__createBuffer)
示例#35
0
    def __init__(self,
                 host,
                 port,
                 timeout=3000,
                 compress=False,
                 connectionStateChangedHandler=None):
        DirectObject.__init__(self)

        self.connectionStateChangedHandler = connectionStateChangedHandler

        self.myConnection = None

        self.host = host
        self.port = port
        self.timeout = timeout
        self.compress = compress

        self.cManager = QueuedConnectionManager()
        self.cReader = QueuedConnectionReader(self.cManager, 0)
        self.cWriter = ConnectionWriter(self.cManager, 0)

        # By default, we are not connected
        self.connected = False

        self.passedData = []

        self.connect(self.host, self.port, self.timeout)
示例#36
0
文件: Arena.py 项目: warycat/Debugger
 def __init__(self):
     DirectObject.__init__(self)
     self.sound = {}
     self.sound['death'] = loader.loadSfx('arena/sound/invisibility.wav')
     self.music = {}
     self.music['complex'] = loader.loadMusic('arena/music/The Complex.mp3')
     self.currentMusic = None 
示例#37
0
 def __init__(self, cr):
     DistributedObject.__init__(self, cr)
     self.colorSet = 0
     self.fadeTime = 0.1
     self.fadeTask = None
     self.xpBonus = 0
     return
    def __init__(self, cam=None):
        PandaNode.__init__(self, 'popup')
        DirectObject.__init__(self)

        self.__mwn = NametagGlobals.mouseWatcher
        self.__name = 'clickregion-%d' % id(self)

        self.__cam = cam
        self.__region = MouseWatcherRegion(self.__name, 0, 0, 0, 0)
        self.__mwn.addRegion(self.__region)

        self.__disabled = False
        self.__clicked = False
        self.__hovered = False
        self.__clickState = 0

        self.__clickEvent = ''
        self.__clickExtraArgs = []

        self.accept(self.__getEvent(self.__mwn.getEnterPattern()),
                    self.__mouseEnter)
        self.accept(self.__getEvent(self.__mwn.getLeavePattern()),
                    self.__mouseLeave)
        self.accept(self.__getEvent(self.__mwn.getButtonDownPattern()),
                    self.__buttonDown)
        self.accept(self.__getEvent(self.__mwn.getButtonUpPattern()),
                    self.__buttonUp)
示例#39
0
 def __init__(self, batIndex, timeToTraverseField):
     NodePath.__init__(self, 'VineBat')
     DirectObject.__init__(self)
     pos = Point3(0, 0, 0)
     serialNum = 0
     gameId = 0
     self.serialNum = serialNum
     self.batIndex = batIndex
     self.timeToTraverseField = timeToTraverseField
     gameAssets = loader.loadModel('phase_4/models/minigames/vine_game')
     bat3 = gameAssets.find('**/bat3')
     bat2 = gameAssets.find('**/bat2')
     bat1 = gameAssets.find('**/bat__1')
     seqNode = SequenceNode.SequenceNode('bat')
     seqNode.addChild(bat1.node())
     seqNode.addChild(bat2.node())
     seqNode.addChild(bat3.node())
     seqNode.setFrameRate(12)
     seqNode.pingpong(False)
     self.batModel = self.attachNewNode(seqNode)
     self.batModel.reparentTo(self)
     gameAssets.removeNode()
     self.batModelIcon = self.attachNewNode('batIcon')
     self.batModel.copyTo(self.batModelIcon)
     regularCamMask = BitMask32.bit(0)
     self.batModelIcon.hide(regularCamMask)
     self.batModelIcon.show(VineGameGlobals.RadarCameraBitmask)
     self.batModelIcon.setScale(0.55)
     self.batModel.setScale(0.15)
     self.setPos(-100, 0, 0)
     center = Point3(0, 0, 0)
     self.sphereName = 'batSphere-%s-%s' % (gameId, self.serialNum)
     self.collSphere = CollisionSphere(center[0], center[1], center[2],
                                       self.RADIUS)
     self.collSphere.setTangible(0)
     self.collNode = CollisionNode(self.sphereName)
     self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask)
     self.collNode.addSolid(self.collSphere)
     self.collNodePath = self.attachNewNode(self.collNode)
     self.collNodePath.hide()
     self.accept('enter' + self.sphereName, self.__handleEnterSphere)
     self.screechSfx = base.loadSfx(
         'phase_4/audio/sfx/MG_sfx_vine_game_bat_shriek_3.mp3')
     self.flySfx = base.loadSfx(
         'phase_4/audio/sfx/MG_sfx_vine_game_bat_flying_lp.wav')
     self.oldCutoffDistance = base.sfxPlayer.getCutoffDistance()
     base.sfxPlayer.setCutoffDistance(240)
     self.soundInterval = SoundInterval(self.flySfx,
                                        node=self,
                                        listenerNode=base.localAvatar,
                                        seamlessLoop=True,
                                        volume=0.5,
                                        cutOff=240)
     self.reparentTo(render)
     self.startedFlying = False
     self.warnedForThisLap = False
     startX = VineGameGlobals.VineXIncrement * VineGameGlobals.NumVines
     endX = -VineGameGlobals.VineXIncrement
     self.velocity = float(startX - endX) / self.timeToTraverseField
     self.warnDistance = 35
示例#40
0
    def __init__(self, url):
        DirectObject.__init__(self)
        
        self.url = URLSpec(url)
        self.image = None

        # Create a condition variable so we can block on load.
        self.cvar = threading.Condition()
        self.done = False

        # Create an initial 1x1 white texture.
        self.tex = Texture(Filename(self.url.getPath()).getBasename())
        p = PNMImage(1, 1)
        p.fill(0.5, 0.5, 1)
        self.tex.load(p)

        if self.url.getScheme() == 'maze':
            # Here's a special case: instead of querying an HTTP
            # server, we get the local poster data from the maze
            # object.
            self.loadPlayerPoster()

        elif self.url.getScheme() == '':
            # Another special case: this is a local file.  This should
            # only happen from the local player.
            self.loadLocalPoster()
            
        else:
            # Otherwise, we get the poster data from the internet.
            self.loadingTask = taskMgr.add(self.load, 'loadPoster', taskChain = 'loadPoster')
    def __init__(self, version='n/a'):
        DirectObject.__init__(self)

        self.backgroundNodePath = render2d.attachNewNode('background', 0)
        self.backgroundModel = loader.loadModel(
            'phase_3/models/gui/loading-background.bam')
        self.backgroundModel.reparentTo(self.backgroundNodePath)
        self.backgroundNodePath.find('**/fg').removeNode()
        self.backgroundNodePath.setScale(1, 1, 1)

        self.logo = OnscreenImage(
            parent=base.a2dTopCenter, image='phase_3/maps/toontown-logo.png',
            scale=(1.0, 1, 0.5), pos=(0, 0, -0.85))
        self.logo.setTransparency(TransparencyAttrib.MAlpha)

        self.label = OnscreenText(
            TTLocalizer.ClickToStartLabel, parent=base.a2dBottomCenter,
            font=ToontownGlobals.getMinnieFont(), fg=Vec4(1, 1, 1, 1),
            scale=0.1, align=TextNode.ACenter)
        self.label.setZ(0.35)

        self.versionLabel = OnscreenText(
            '\x01white_shadow\x01%s\x02' % version, parent=base.a2dBottomRight,
            font=ToontownGlobals.getMinnieFont(), fg=Vec4(0, 0, 0, 1),
            scale=0.06, align=TextNode.ARight)
        self.versionLabel.setPos(-0.025, 0.025)

        self.setColorScale(Vec4(0, 0, 0, 0))

        self.fadeTrack = None
        self.logoPosTrack = None
        self.logoScaleTrack = None
        self.labelPosTrack = None
        self.labelColorScaleTrack = None
示例#42
0
    def __init__(self, phone, doneEvent=None):
        NodePath.__init__(self, aspect2d.attachNewNode('CatalogGUI'))
        DirectObject.__init__(self)

        CatalogGlobals.CatalogNodePath.find('**/CATALOG_GUI_BKGD').copyTo(self)
        self.setScale(CatalogGlobals.CatalogBKGDScale)

        self.phone = phone
        self.doneEvent = doneEvent

        self.arrowButtons = {}
        self.createArrowButtons()

        self.currentTab = None
        self.tabButtons = {}
        self.createTabButtons()

        self.radioButtons = []
        # self.createRadioButtons()

        self.activePage = 0
        self.gifting = -1

        guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui')
        hangupGui = guiItems.find('**/hangup')
        hangupRolloverGui = guiItems.find('**/hangup_rollover')
        self.hangup = DirectButton(self, relief=None, pos=(2.28, 0, -1.3),
                                   image=[hangupGui, hangupRolloverGui, hangupRolloverGui, hangupGui],
                                   text=['', TTLocalizer.CatalogHangUp, TTLocalizer.CatalogHangUp],
                                   text_fg=Vec4(1), text_scale=0.07, text_pos=(0.0, 0.14),
                                   command=self.hangUp)
        guiItems.removeNode()
示例#43
0
文件: gamingcam.py 项目: onze/goLive
 def __init__(self,gmap,gaming_zone):
    DirectObject.__init__(self)
    #gaming zone (used for mouse movement), as a tools.Rectangle
    self.gaming_zone=gaming_zone
    #actual camera node
    self.p3dcam=base.camera
    #what the cam is oriented to
    self._target=base.render.attachNewNode('GaminCam.target')
    #range=[0,1] between min and max closeness to ground
    self.level=.7
    #
    #keys_down acts as a pool containing keys (+mouse buttons) currently down
    self.keys_down=[]
    update_list.append(self.update)
    #setup for mouse picking
    picker_node=CollisionNode('gcam_to_mouse_ray')#general collision node
    picker_node.setFromCollideMask(GeomNode.getDefaultCollideMask())
    self.picker_ray=CollisionRay()#solid ray to attach to coll node
    picker_node.addSolid(self.picker_ray)
    self.picker_np=self.p3dcam.attachNewNode(picker_node)#attach this node to gcam
    self.collision_queue=CollisionHandlerQueue()#stores collisions
    self.collision_traverser=CollisionTraverser('gcam_traverser')#actual computer
    self.collision_traverser.addCollider(self.picker_np,self.collision_queue)
    base.cTrav=self.collision_traverser
    self.gmap=gmap
    #stack of states (state=pos+zoom)
    self.states_stack=[]
    #enable the cam to move according to keyboard and mouse
    self.move_enabled=True
示例#44
0
    def __init__(self, showbase):
        DirectObject.__init__(self)

        # Initialise Window
        self.showbase = showbase

        # total time since start of game, to keep ticks updating on time (rather, not before)
        self.totalTime = 0

        # packets queue
        self.incoming = deque()

        users = []
        for user in self.showbase.users:
            user.gameData = UserData(user.name == self.showbase.username)
            users.append(user.gameData)
        self.game = Game(self.showbase, users, self.showbase.gameData)
        self.gameHandler = GameHandler(self.showbase, self.game)

        self.tick = 0
        self.tempTick = 0

        # Set event handlers for keys
        # self.showbase.accept("escape", sys.exit)

        # send loading completion packet to the game server
        self.showbase.client.sendData(('round', 'sync'))

        # Add the game loop procedure to the task manager.
        self.showbase.taskMgr.add(self.gameLoop, 'Game Loop')
示例#45
0
文件: gmenu.py 项目: onze/goLive
	def __init__(self,*args,**kwargs):
		DirectObject.__init__(self)
		kwargs['fill']=165,255,121
		kwargs['layout']=HLayout
		Frame.__init__(self,*args,**kwargs)
		self.read_keys_from_config()
		#'type','unit','conf'
		self.state='type'
		self.launch_btn=Button(	pref_w=self.h*2,
										pref_h=self.h,
										p3dobject=DirectButton(	geom=(self.resources['cancel_btn']),
																		borderWidth=(0,0),
																		command=self.cancel),
										parent=self)
		self.accept(self.keys['cancel']+'-up',self.cancel)
		#graphical aspect: [cancel_btn | unit_type_panel | unit_selection_panel | unit_configuration_panel | launch_btn]
		self.type_pan=UnitTypePanel(self)
		self.type_pan.focus()
		self.sel_pan=UnitSelectionPanel(self)
		self.sel_pan.request('Blank')
		self.conf_pan=UnitConfigurationPanel(self)
		self.conf_pan.request('Blank')
		Spacer(parent=self)
		self.launch_btn=Button(	pref_w=self.h*2,
							    pref_h=self.h,
								p3dobject=DirectButton(geom=(self.resources['launch_btn']),
														borderWidth=(0,0),
														command=self.launch_unit),
								parent=self)
		self.accept('enter-up',self.launch_unit)
		self.accept(self.keys['launch']+'-up',self.launch_unit)
		self.accept('mouse3-up',self.launch_unit)
    def __init__(self):
        DirectObject.__init__(self)

        self.pathSmoothening = False
        self.showWaypoints = True
        self.showCollisions = False

        self.accept("escape", sys.exit)

        self.__setupEnvironment()
        self.__setupCollisions()
        self.__setupGravity()
        self.__setupLevel()
        self.__setupTarget()
        self.__setupNPC()
        self.__setupCamera()
        self.__setupTasks()

        self.setKeymap()
        self.__NPC.pathSmoothening = self.pathSmoothening

        if (self.showWaypoints):
            print("Showing waypoints")
            for w in self.roomWaypoints:
                w.draw()
示例#47
0
   def __init__(self):
     DirectObject.__init__(self)
     #
     #self.accept('escape-up', self.quitme)
     # crea ost di debug
     self.display={}
     l=0
     for x in ['joy', 'mouse', 'kb', 'unspecified']:
       l+=1
       self.display[x]=text2d(line=l, text=x.upper()+":")
     ###
     # bind eventi device di input
     #file.cfg tipo quake3
     cfg="""//JOY ------
 bind joy0-button9 "quit" // a comment
 bind joy0-button1 "action"
 bind joy0-axis1 "axis1"
 //KB ------
 bind arrow_up "forward"
 bind escape "quit"
 bind enter "action"
 // MOUSE ------
 bind mouse1 "action"
 """
     #these are the allowed handlers we need
     hndbridge={
       'axis1': self.axis1test,
       'action': self.allaction,
       'quit': self.quitme,
     }
     #
     self.xinput=easyinput(cfg, hndbridge)
示例#48
0
    def __init__(self, debug_ui):
        """
        @param debug_ui: The parent DebugUI
        @type debug_ui: DebugUI
        """
        DirectObject.__init__(self)
        Notifier.__init__(self, "ui-games-list")
        List.__init__(self,
                      debug_ui.messager.games,
                      10, (-1.1, 0.6),
                      command=self.game_clicked)

        self.debug_ui = debug_ui

        self.btn_title = DirectButton(scale=self.scale,
                                      text="Games",
                                      pos=(-1.1, 1, .8),
                                      frameSize=self.frame_size,
                                      command=self.debug_ui.switch_list,
                                      extraArgs=[1],
                                      state=DGG.DISABLED,
                                      relief=DGG.SUNKEN)

        self.accept("arrow_right", self.next_page)
        self.accept("arrow_left", self.previous_page)

        self.notify.info("[__init__] Created GamesList")
示例#49
0
    def __init__(self, showbase, game):
        DirectObject.__init__(self)

        self.client = showbase.client
        self.game = game

        # Keys array (down if 1, up if 0)
        self.keys = {"left": 0, "right": 0, "up": 0, "down": 0, "c": 0}

        # holding c will focus the camera on clients warlock
        self.accept("c", self.setValue, [self.keys, "c", 1])
        self.accept("c-up", self.setValue, [self.keys, "c", 0])

        # mouse 1 is for casting the spell set by the keys
        # showbase.accept("mouse1", self.castSpell)

        # mouse 3 is for movement, or canceling keys for casting spell
        self.accept("mouse3", self.updateDestination)

        self.ch = CameraHandler(showbase)

        # sets the camera up behind clients warlock looking down on it from angle
        follow = self.game.centipede.head
        self.ch.setTarget(follow.getPos().getX(),
                          follow.getPos().getY(),
                          follow.getPos().getZ())
        self.ch.turnCameraAroundPoint(follow.getH(), 0)
示例#50
0
    def __init__(self, base):
        DirectObject.__init__(self)
        self.base = base
        self.lastUpdate = 0.0

        # Load car model
        self.car = self.base.loader.loadModel("models/car")
        self.car.reparentTo(self.base.render)

        # Parameters
        self.wheelFront = Vec3(1.0, 0.0, 0.0) * 3.37
        self.wheelBack = Vec3(-1.0, 0.0, 0.0) * 3.62

        # Car properties
        self.position = Point3(0.0, 0.0, 0.0)
        self.steerAngle = 10.0
        self.speed = 5.0

        # Controls
        self.upArrowDown = False
        self.leftArrowDown = False
        self.rightArrowDown = False
        self.accept("arrow_up", self.onUpArrow, [True])
        self.accept("arrow_up-up", self.onUpArrow, [False])
        self.accept("arrow_left", self.onLeftArrow, [True])
        self.accept("arrow_left-up", self.onLeftArrow, [False])
        self.accept("arrow_right", self.onRightArrow, [True])
        self.accept("arrow_right-up", self.onRightArrow, [False])
        self.base.taskMgr.add(self.updateCar, "UpdateCarTask")

        # DEBUG
        self.drawAxis(10)
        self.drawWheelBase()
示例#51
0
    def __init__(self, parent_node, y=0):
        DirectObject.__init__(self)
        self.accept(Event.COMBAT_DATA_PARSED, self.handle_combat_data_parsed)
        self.node = parent_node.attach_new_node("action bar")
        self.frame = Frame(parent_node=self.node,
                           color=(0, 0, 0, 0.6),
                           x=0,
                           y=0.01,
                           width=0.25,
                           height=0.047)
        self.y = y
        x_offset = 0.026
        spell_slot_width = 0.025
        padding = 0.003
        y_offset = 0.057
        self.spell_slots = []
        tracker_classes = [
            TrackerSpell1, TrackerSpell2, TrackerSpell3, TrackerSpell4
        ]
        for i in range(self.N_SLOTS):
            if i in range(0, len(tracker_classes)):
                tracker_cls = tracker_classes[i]
            else:
                tracker_cls = None

            slot = SpellSlot(node=self.node,
                             tracker_cls=tracker_cls,
                             x_offset=x_offset,
                             y_offset=y_offset,
                             parent_frame=None)
            self.spell_slots.append(slot)
            # self.set_cooldown_tracking()
            x_offset += spell_slot_width + padding

        self.accept("aspectRatioChanged", self.aspect_ratio_change_update)
示例#52
0
 def __init__(self, name, worldNode, mapGeom):
     DirectObject.__init__(self)
     self.map = None
     self.worldNode = worldNode
     self.mapNode = NodePath(name)
     self.mapGeom = mapGeom.copyTo(self.mapNode)
     self.overlayNode = NodePath(name)
 def __init__(self, res = (32, 16),
              unwrap_state = 0.0, unwrap_target = 0.0, unwrap_time = 0.4,
              base_zoom = 0.02, base_zoom_max_dist = 1.0,
              camera_max_dist = 4.0, camera_min_dist = 0.15, camera_dist = 3.0, ):
     DirectObject.__init__(self)
     self.res = res
     self.unwrap_state = unwrap_state
     self.unwrap_target = unwrap_target
     self.unwrap_time = unwrap_time
     self.base_zoom = base_zoom
     self.base_zoom_max_dist = base_zoom_max_dist
     self.camera_max_dist = camera_max_dist
     self.camera_min_dist = camera_min_dist
     self.camera_dist = camera_dist
     # Bases
     base.taskMgr.add(self.refresh_geosphere, 'refresh_geosphere', sort = 10)
     self.bases = []
     self.connections = []
     # Camera management
     base.camera.set_pos(0, -10, 0)
     base.camera.look_at(0, 0, 0)
     self.camera_position = [0.5, 0.8]
     self.camera_movement = [0.0, 0.0]
     self.camera_distance = 3.0
     self.camera_controlled = False
示例#54
0
 def __init__(self, air):
     DirectObject.__init__(self)
     self.air = air
     self.currentHolidays = []
     self.xpMultiplier = 3
     self.setup()
     self.checkForHoliday('checkForHoliday')
示例#55
0
    def __init__(self):
        DirectObject.__init__(self)
        self.accept("escape", self.quit)
        self.lastConnection = None
        self.cManager = QueuedConnectionManager()
        self.cListener = QueuedConnectionListener(self.cManager, 0)
        self.cReader = QueuedConnectionReader(self.cManager, 0)
        self.cWriter = ConnectionWriter(self.cManager,0)
        self.tcpSocket = self.cManager.openTCPServerRendezvous(SERVER_PORT, 1)
        self.cListener.addConnection(self.tcpSocket)
        taskMgr.add(self.listenTask, "serverListenTask", -40)
        taskMgr.add(self.readTask, "serverReadTask", -39)

        self.gameLogic = GameLogic()
        self.gameLogic.delegate = self;

        blackmaker = CardMaker("blackmaker")
        blackmaker.setColor(0,0,0,1)
        blackmaker.setFrame(-1.0, 1.0, -1.0, 1.0)
        instcard = NodePath(blackmaker.generate())
        instcard.reparentTo(render2d)

        self.screenText = OnscreenText(text="Server started ...\n",
            style=1, fg=(1,1,1,1), pos=(-1.31, 0.925), scale = .06)
        self.screenText.setAlign(0)
示例#56
0
 def __init__(self, gsg = None, limit = None):
     DirectObject.__init__(self)
     self.name = 'tex-mem%s' % TexMemWatcher.NextIndex
     TexMemWatcher.NextIndex += 1
     self.cleanedUp = False
     self.top = 1.0
     self.quantize = 1
     self.maxHeight = base.config.GetInt('tex-mem-max-height', 300)
     self.totalSize = 0
     self.placedSize = 0
     self.placedQSize = 0
     if gsg is None:
         gsg = base.win.getGsg()
     elif isinstance(gsg, GraphicsOutput):
         gsg = gsg.getGsg()
     self.gsg = gsg
     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
     moduleName = base.config.GetString('tex-mem-pipe', '')
     if moduleName:
         self.pipe = base.makeModulePipe(moduleName)
     if not self.pipe:
         self.pipe = base.pipe
     self.win = base.graphicsEngine.makeOutput(self.pipe, name, 0, fbprops, props, flags)
     self.win.setSort(10000)
     self.win.setClearColorActive(False)
     self.win.setClearDepthActive(False)
     eventName = '%s-window' % self.name
     self.win.setWindowEvent(eventName)
     self.accept(eventName, self.windowEvent)
     self.accept('graphics_memory_limit_changed', self.graphicsMemoryLimitChanged)
     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()
     self.background = None
     self.nextTexRecordKey = 0
     self.rollover = None
     self.isolate = None
     self.isolated = None
     self.needsRepack = False
     updateInterval = base.config.GetDouble('tex-mem-update-interval', 0.5)
     self.task = taskMgr.doMethodLater(updateInterval, self.updateTextures, 'TexMemWatcher')
     self.setLimit(limit)
     return
示例#57
0
文件: Arena.py 项目: warycat/Debugger
 def __init__(self):
     DirectObject.__init__(self)
     self.collisionRay = CollisionRay()
     self.collisionNode = CollisionNode('mouseray')
     self.collisionNode.set_into_collide_mask(0)
     self.collisionNode.addSolid(self.collisionRay)
     self.collisionNodePath = base.camera.attachNewNode(self.collisionNode)
     base.cTrav.addCollider(self.collisionNodePath,base.collisionHandlerEvent)    
示例#58
0
 def __init__(self):
     DirectObject.__init__(self)
     self.__fsm = SeriousFSM()
     self.accept("serious_menu",self.__menu_window)
     self.accept("serious_new_game",self.__new_game_window)
     self.accept("serious_load_game",self.__load_game_window)
     self.accept("serious_description",self.__description)
     self.__fsm.request('Menu')
示例#59
0
 def __init__(self, mg):
     DirectObject.__init__(self)
     self.actualAvatar = base.localAvatar
     self.beansCollected = 0
     self.moneyGui = None
     self.mg = mg
     self.toonFPS = FactorySneakGameToonFPS(mg)
     return
    def __init__(self, experimentEvent, challengeId, completionBlock, needed):
        DirectObject.__init__(self)

        self.experimentEvent = experimentEvent
        self.challengeId = challengeId
        self.needed = needed
        self.count = 0

        self.completionBlock = completionBlock