当前位置: 首页>>代码示例>>Python>>正文


Python World.World类代码示例

本文整理汇总了Python中World.World的典型用法代码示例。如果您正苦于以下问题:Python World类的具体用法?Python World怎么用?Python World使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了World类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _set_ref

    def _set_ref(self, new_ref_name):
        '''Changes the reference frame of the action step'''
        new_ref = World.get_ref_from_name(new_ref_name)
        if (new_ref != ArmState.ROBOT_BASE):
            index = ActionStepMarker._ref_names.index(new_ref_name)
            new_ref_obj = ActionStepMarker._ref_object_list[index - 1]
        else:
            new_ref_obj = Object()

        if (self.action_step.type == ActionStep.ARM_TARGET):
            if self.arm_index == 0:
                self.action_step.armTarget.rArm = World.convert_ref_frame(
                        self.action_step.armTarget.rArm, new_ref, new_ref_obj)
            else:
                self.action_step.armTarget.lArm = World.convert_ref_frame(
                        self.action_step.armTarget.lArm, new_ref, new_ref_obj)
        elif (self.action_step.type == ActionStep.ARM_TRAJECTORY):
            for i in range(len(self.action_step.armTrajectory.timing)):
                if self.arm_index == 0:
                    arm_old = self.action_step.armTrajectory.rArm[i]
                    arm_new = World.convert_ref_frame(arm_old,
                                                      new_ref, new_ref_obj)
                    self.action_step.armTrajectory.rArm[i] = arm_new
                else:
                    arm_old = self.action_step.armTrajectory.lArm[i]
                    arm_new = World.convert_ref_frame(arm_old,
                                                      new_ref, new_ref_obj)
                    self.action_step.armTrajectory.lArm[i] = arm_new
            if self.arm_index == 0:
                self.action_step.armTrajectory.rRefFrameObject = new_ref_obj
                self.action_step.armTrajectory.rRefFrame = new_ref
            else:
                self.action_step.armTrajectory.lRefFrameObject = new_ref_obj
                self.action_step.armTrajectory.lRefFrame = new_ref
开发者ID:mayacakmak,项目名称:pr2_pbd,代码行数:34,代码来源:ActionStepMarker.py

示例2: __init__

class Application:

    def __init__(self):

        pygame.init()
        pygame.display.set_caption('SideScroller')
        pygame.display.set_mode([1024,600])

        self.world = World()
        self.world.addManager('player',MovementManager())
        self.world.addManager('scrollable',ScrollManager())
        self.world.addManager('friction',FrictionManager())
        self.world.load('lvl/maps.txt','lvl/1.txt')
        self.clock = pygame.time.Clock()
        self.go = True

    def loop(self):

        while self.go:
            events = pygame.event.get()
            for event in events:
                if event.type == pygame.QUIT:
                    sys.exit()

            self.clock.tick(60)
            self.world.update( events )
            self.world.draw(pygame.display.get_surface())
            pygame.display.flip()
开发者ID:tomverran,项目名称:Sidescroller,代码行数:28,代码来源:App.py

示例3: init

def init():
    """
    Game initialization function.
        1. Creates a L{Debugger} (debugger) and L{EventTimer} (eventTimer) and 
           stores references to them in an instance of L{EventManager}.
        2. Several listeners are started and registered with eventManager:
            - Instance of L{Universe} (universe)
            - Instance of L{UserInterface} (ui)
            - Instance of L{Window} (gameWindow)
        3. We send the eventManager a message to start the game
            - This message is interpreted by the gameWindow
    """
    
    debugger = Debugger()
    eventTimer = EventTimer()
    
    #Create the event manager for low-level events
    eventManager = Manager(eventTimer,debugger) #FIXME: more specific manager\
                                                #classes will be needed later?
    try:                                            
        client = GameClient(eventManager,host='10.41.24.79',port=1567)
    except:
        pass
    
    #Create the occurence manager for high-level events (same across client and server)
    #FIXME: NOT YET IMPLEMENTED
    #Note: Do we even need this anymore? - Julian
    #Response: I don't think so.  - Jared
    
    #===========================================
    #Create and register the standard listeners
    #With the event manager
    #===========================================
    #FIXME: Not yet fully implemented
    
    #THIS WILL BE CHANGED LATER TO ACCOUNT FOR LOADING, ETC.

    # World w is set to the activeWorld of the universe
    universe = Universe(eventManager)
    ui = UserInterface(eventManager,universe.activeWorld)
    
    gameWindow = Window(eventManager,width=1024,height=768)
    
    w = World()
    universe.changeWorld(w)
    
    #===========================================
    
    # Initialize 500 entities in World w
    for i in range(100):
        #w.addEntity(Entity('ball.png',i*50,i*50, w, (255,255,255)))
        #w.addEntity(TestEntity('testBuilding.png', i*50, i*50, w, 'alpha'))
        w.addEntity(TestEntity('testCraft.png',i*50,i*50,w,'alpha'))

    eventManager.post(Event.WorldManipulationEvent())
    
    #Notify the manager that the window should start to accept input:
    eventManager.post(Event.StartEvent())
    return eventManager.eventTypesToListeners
开发者ID:jceipek,项目名称:Complete-Galactic-Dominion,代码行数:59,代码来源:testClient.py

示例4: _offset_pose

 def _offset_pose(pose, constant=1):
     '''Offsets the world pose for visualization'''
     transform = World.get_matrix_from_pose(pose)
     offset_array = [constant * ActionStepMarker._offset, 0, 0]
     offset_transform = tf.transformations.translation_matrix(offset_array)
     hand_transform = tf.transformations.concatenate_matrices(transform,
                                                     offset_transform)
     return World.get_pose_from_transform(hand_transform)
开发者ID:mayacakmak,项目名称:pr2_pbd,代码行数:8,代码来源:ActionStepMarker.py

示例5: build

    def build(self):
        Config.set('graphics', 'width', self.settings.WINDOW_WIDTH)
        Config.set('graphics', 'height', self.settings.WINDOW_HEIGHT)

        game = World(self.settings)
        game.draw()
        Clock.schedule_interval(game.update, self.settings.UPDATE_SPEED)
        return game
开发者ID:NoRxn,项目名称:PathFinder,代码行数:8,代码来源:PathFinder.py

示例6: _make_gripper_marker

    def _make_gripper_marker(self, control, is_hand_open=False):
        '''Makes a gripper marker'''
        if is_hand_open:
            angle = 28 * numpy.pi / 180.0
        else:
            angle = 0

        transform1 = tf.transformations.euler_matrix(0, 0, angle)
        transform1[:3, 3] = [0.07691 - ActionStepMarker._offset, 0.01, 0]
        transform2 = tf.transformations.euler_matrix(0, 0, -angle)
        transform2[:3, 3] = [0.09137, 0.00495, 0]
        t_proximal = transform1
        t_distal = tf.transformations.concatenate_matrices(transform1,
                                                           transform2)

        mesh1 = self._make_mesh_marker()
        mesh1.mesh_resource = ('package://pr2_description/meshes/' +
                                'gripper_v0/gripper_palm.dae')
        mesh1.pose.position.x = -ActionStepMarker._offset
        mesh1.pose.orientation.w = 1

        mesh2 = self._make_mesh_marker()
        mesh2.mesh_resource = ('package://pr2_description/meshes/' +
                               'gripper_v0/l_finger.dae')
        mesh2.pose = World.get_pose_from_transform(t_proximal)

        mesh3 = self._make_mesh_marker()
        mesh3.mesh_resource = ('package://pr2_description/meshes/' +
                               'gripper_v0/l_finger_tip.dae')
        mesh3.pose = World.get_pose_from_transform(t_distal)

        quat = tf.transformations.quaternion_multiply(
                    tf.transformations.quaternion_from_euler(numpy.pi, 0, 0),
                    tf.transformations.quaternion_from_euler(0, 0, angle))
        transform1 = tf.transformations.quaternion_matrix(quat)
        transform1[:3, 3] = [0.07691 - ActionStepMarker._offset, -0.01, 0]
        transform2 = tf.transformations.euler_matrix(0, 0, -angle)
        transform2[:3, 3] = [0.09137, 0.00495, 0]
        t_proximal = transform1
        t_distal = tf.transformations.concatenate_matrices(transform1,
                                                           transform2)

        mesh4 = self._make_mesh_marker()
        mesh4.mesh_resource = ('package://pr2_description/meshes/' +
                               'gripper_v0/l_finger.dae')
        mesh4.pose = World.get_pose_from_transform(t_proximal)
        mesh5 = self._make_mesh_marker()
        mesh5.mesh_resource = ('package://pr2_description/meshes/' +
                               'gripper_v0/l_finger_tip.dae')
        mesh5.pose = World.get_pose_from_transform(t_distal)

        control.markers.append(mesh1)
        control.markers.append(mesh2)
        control.markers.append(mesh3)
        control.markers.append(mesh4)
        control.markers.append(mesh5)

        return control
开发者ID:mayacakmak,项目名称:pr2_pbd,代码行数:58,代码来源:ActionStepMarker.py

示例7: __init__

    def __init__(self, interactive=False, delay=100):
        World.__init__(self)
        self.delay = delay
        self.title('AmoebaWorld')
        self.running = False

        self.make_canvas()
        if interactive:
            self.make_control_panel()
开发者ID:AlexCSoh,项目名称:dev-sprint0,代码行数:9,代码来源:AmoebaWorld.py

示例8: init

def init(host='localhost',server=None):
    """
    Most of this code is copied from init() function in client.py
    
    Game initialization function.
        1. Creates a L{Debugger} (debugger) and L{EventTimer} (eventTimer) and 
           stores references to them in an instance of L{EventManager}.
        2. Several listeners are started and registered with eventManager:
            - Instance of L{Universe} (universe)
            - Instance of L{UserInterface} (ui)
            - Instance of L{Window} (gameWindow)
        3. We send the eventManager a message to start the game
            - This message is interpreted by the gameWindow
    """
    
    #Creates a Debugger that posts events to the terminal for debugging purposes
    debugger = Debugger()
    eventTimer = EventTimer()
    
    #Create the event manager for low-level events
    eventManager = Manager(eventTimer,debugger) #FIXME: more specific manager\
    Entity.manager = eventManager    

    # World w is set to the activeWorld of the universe
    universe = Universe(eventManager)
    ui = UserInterface(eventManager,universe.activeWorld,'BROADCASTSERVER')

    gameWindow = Window(eventManager,width=1024,height=768)
    gameWindow.fullscreenMode = False
    gameWindow.updateScreenMode()

    w = World(universe)
    s.world=w

    networked = True
    client = GameClient(eventManager,host=s.host,port=1567)

	#wait until the client is assigned an ID before proceeding
    while client.ID == None:
        import time
        time.sleep(.02)
    print 'Got an ID',client.ID
    clientID = client.ID

    ui.setClientID(clientID)

    wManipulator = WorldManipulator(eventManager,w,networked,gameClientID = clientID)
    
    #generate the resources in the server, the existance of these
    #resources will propogate through to every client when they connect
    w._generateResources()
    
    #Notify the manager that the window should start to accept input:
    eventManager.post(Event.StartEvent())

    return eventManager.eventTypesToListeners
开发者ID:jceipek,项目名称:Complete-Galactic-Dominion,代码行数:56,代码来源:broadcastServer.py

示例9: __init__

 def __init__(self,r=1.0,s=1.0,v=1.0,cloudsize=1.0) :
     World.__init__(self,r,s,v,cloudsize)
     Tk.__init__(self)
     self.title("World")
     self.iconname("World")
     self.frame = Frame(self)
     self.frame.pack(side=TOP,expand=YES,fill=BOTH)
     self.setupMenu()
     self.setupWindow()
     self.setupOptionsEntry()
开发者ID:cu-madc,项目名称:vacuum,代码行数:10,代码来源:GraphicalWorld.py

示例10: __init__

    def __init__(self, canvas_size=500, cell_size=10, interactive=False):
        World.__init__(self)
        self.title('GIS Modling and Problem Solving Final Project')
        self.canvas_size = canvas_size
        self.cell_size = cell_size
        self.cells = {}

        if interactive:
            self.make_canvas()
            self.make_control()
开发者ID:sherpashaky,项目名称:GISModeling_FinalProject,代码行数:10,代码来源:SourceCode.py

示例11: __init__

    def __init__(self, interactive=False):
        World.__init__(self)
        self.title("TurtleWorld")

        # the interpreter executes user-provided code
        self.make_interpreter(globals())

        # make the GUI
        self.setup()
        if interactive:
            self.setup_interactive()
开发者ID:jfparis,项目名称:swampy,代码行数:11,代码来源:TurtleWorld.py

示例12: startNewSim

 def startNewSim(self,simParam):
     self.stopSimulation()
     with self.lock:
         self.thread_exit = False
         self.isRunning = True
     self.worldBuffer = Queue.Queue()
     world = World(simParam)                                       #starts the world
     self.staticWorld = copy.deepcopy(world)               #static copy to merge and send to GUI
     self.worldBuffer.put((0,world.copyDynamicState()))    #puts dynamic state in the first spot
     self.simThread = threading.Thread(target=self.simulate, args=(world, 0, 1))   #runs the thread
     self.runTimeS = time.clock()
     self.simThread.start()
开发者ID:RyanAshbaugh,项目名称:AnimatSimulation,代码行数:12,代码来源:SimulationEngine.py

示例13: __init__

    def __init__(self, canvas_size=500, cell_size=5, interactive=False):
        World.__init__(self)
        self.title('CellWorld')
        self.canvas_size = canvas_size
        self.cell_size = cell_size    

        # cells is a map from index tuples to Cell objects
        self.cells = {}

        if interactive:
            self.make_canvas()
            self.make_control()
开发者ID:BethWIntera,项目名称:Beths_PySandbox,代码行数:12,代码来源:CellWorld.py

示例14: extract_startsize

def extract_startsize(a):
    beetype, formation, formnumber, seed = a
    w = World(beetype,
              len(formation),
              len(formation)*2,
              len(formation)*2,
              {"seed":0, "formation":formation},
              seed,
              True)
    w.stepForward()
    i = 0
    return [seed, beetype.__name__, formnumber,  w.sizeOfWorld]   
开发者ID:Wieke,项目名称:bee-formation,代码行数:12,代码来源:batch-performance-test.py

示例15: __init__

    def __init__(self, interactive=False):
        World.__init__(self)
        self.title('TurtleWorld')

        # the interpreter executes user-provided code
        g = globals()
        g['world'] = self
        self.make_interpreter(g)

        # make the GUI
        self.setup()
        if interactive:
            self.setup_interactive()
开发者ID:cassiesancartier,项目名称:dev-sprint0,代码行数:13,代码来源:TurtleWorld.py


注:本文中的World.World类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。