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


Python GameLogic.getCurrentController方法代码示例

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


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

示例1: main

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def main():
    if GameLogic.Object['closed']:
        return
    # get controller
    controller = GameLogic.getCurrentController()
    gu.keep_conn([conn1, conn2])
    
    obj = controller.owner
    pos = obj.localPosition
    ori = obj.localOrientation
    try:
        arduino = serial.Serial('/dev/arduino_ethernet', 9600)
    
        if x1_in <= pos[0] <= x_out and y_in <= pos[1] <= y_out:
            arduino.write(b'A')
        elif -x1_in >= pos[0] >= -x_out and -y_in >= pos[1] >= -y_out:
            arduino.write(b'B')
        else:
            arduino.write(b'L')    
    except:
        print("No reward")
    
    if conn1 is not None:
        # get mouse movement
        t1, dt1, x1, y1 = gu.read32(conn1)
        t2, dt2, x2, y2 = gu.read32(conn2)
    else:
        t1, dt1, x1, y1 = np.array([0,]), np.array([0,]), np.array([0,]), np.array([0,])
        t2, dt2, x2, y2 = np.array([0,]), np.array([0,]), np.array([0,]), np.array([0,])   
    # move according to ball readout:
    movement(controller, (x1, y1, x2, y2, t1, t2, dt1, dt2))
开发者ID:kemerelab,项目名称:VR_Ball,代码行数:33,代码来源:camera_l.py

示例2: quit

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def quit():
    """ Cleanly quit the simulation
    """

    contr = GameLogic.getCurrentController()
    main_close(contr)
    main_terminate(contr)
开发者ID:nttputus,项目名称:morse,代码行数:9,代码来源:supervision_services.py

示例3: default_action

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
    def default_action(self):
        """ Change the 'Severity' property of a nearby victim

        When the victim is fully healed, set its status as not Injured
        """
        contr = GameLogic.getCurrentController()
        radar = contr.sensors["Radar"]

        if self.local_data["heal"]:
            if radar.triggered and radar.positive:
                victim = radar.hitObject

                # Restore the health to the victim
                if victim["Severity"] > 0:
                    victim["Severity"] = victim["Severity"] - 1
                    # Set the colors depending on the severity of the injuries
                    red = 1 - victim["Severity"] * 0.05
                    green = 0.5 + red
                    victim.color = [red, green, 0.5, 1.0]

                # Change the status
                if victim["Severity"] == 0:
                    victim["Injured"] = False
                    # Reset the healing flag
                    self.local_data["heal"] = 0
开发者ID:peterroelants,项目名称:morse,代码行数:27,代码来源:healer.py

示例4: default_action

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
    def default_action(self):
        """ Look for nearby victims, and heal when instructed to """
        # Look for victims in the cone of the sensor
        contr = GameLogic.getCurrentController()
        radar = contr.sensors['Radar']
        if radar.triggered and radar.positive:
            for victim_obj in radar.hitObjectList:
                victim_position = victim_obj.worldPosition
                # Fill the data structure for the victim
                victim_coordinate = OrderedDict([
                                ('x', victim_position[0]),
                                ('y', victim_position[1]),
                                ('z', victim_position[2])   ])
                victim_data = OrderedDict([
                                ('coordinate', victim_coordinate),
                                ('requirements', victim_obj['Requirements']),
                                ('severity', victim_obj['Severity'])    ])
                self.local_data['victim_dict'][victim_obj.name] = victim_data

                # Find the closest victim and its distance
                new_distance = self.blender_obj.getDistanceTo(victim_obj)
                if new_distance < self._nearest_distance:
                    self._nearest_victim = victim_obj
                    self._nearest_distance = new_distance

            # When instructed to do so, help a victim
            if self._healing:
                self._heal_victim()

        if radar.triggered and not radar.positive:
            # Clear the variables for the victims
            self.local_data['victim_dict'] = {}
            self._nearest_victim = None
            self._nearest_distance = 999999
开发者ID:gilecheverria,项目名称:morse,代码行数:36,代码来源:rosace.py

示例5: default_action

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
    def default_action(self):
        """ Look for nearby victims, and heal when instructed to """
        # Look for victims in the cone of the sensor
        contr = GameLogic.getCurrentController()
        radar = contr.sensors['Radar']
        if radar.triggered and radar.positive:
            for victim_obj in radar.hitObjectList:
                victim_position = victim_obj.worldPosition
                self.local_data['victim_dict'][victim_obj.name] = [victim_position[0], victim_position[1], victim_position[2]]

                # Find the closest victim and its distance
                new_distance = self.blender_obj.getDistanceTo(victim_obj)
                if new_distance < self._nearest_distance:
                    self._nearest_victim = victim_obj
                    self._nearest_distance = new_distance

            # When instructed to do so, help a victim
            if self._healing:
                self._heal_victim()

        if radar.triggered and not radar.positive:
            # Clear the variables for the victims
            self.local_data['victim_dict'] = {}
            self._nearest_victim = None
            self._nearest_distance = 999999
开发者ID:peterroelants,项目名称:morse,代码行数:27,代码来源:rosace.py

示例6: main

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def main():
    if GameLogic.Object['closed']:
        return

    # get controller
    controller = GameLogic.getCurrentController()

    nmouse = 1
    mkey = 'm%dconn' % (nmouse) 
    if mkey in GameLogic.Object.keys():
        t1, dt1, x1, y1 = gu.read32(GameLogic.Object[mkey])
        gu.keep_conn([GameLogic.Object[mkey]])
    else:
        t1, dt1, x1, y1 = 0, 0, np.array([0,]), np.array([0,])
    nmouse = 2
    mkey = 'm%dconn' % (nmouse) 
    if mkey in GameLogic.Object.keys():
        t2, dt2, x2, y2 = gu.read32(GameLogic.Object[mkey])
        gu.keep_conn([GameLogic.Object[mkey]])
    else:
        t2, dt2, x2, y2 = 0, 0, np.array([0,]), np.array([0,])

    
    # move according to ball readout:
    movement(controller, (x1, y1, x2, y2, t1, t2, dt1, dt2))
开发者ID:neurodroid,项目名称:gnoom,代码行数:27,代码来源:evread.py

示例7: main

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def main():
 
    # Get owner
    controller = GameLogic.getCurrentController()
    owner = controller.owner
    Host = 'localhost'
    ServerPort = 10000
     
    # Set socket server only one time at the first frame
    if not owner['OneTime']:
        # Set UDP socket
        GameLogic.sServer = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     
        # Bind the socket to host
        GameLogic.sServer.bind((Host, ServerPort))
     
        # If no data are found, pass
        GameLogic.sServer.setblocking(0)
     
        # Set prop to pass test
        owner['OneTime'] = True
     
    # Get Position and Orientation
    PosCar = owner.worldPosition
    OriCar = owner.worldOrientation
     
    # New in python 3
    stupid = (PosCar[0], PosCar[1], PosCar[2], OriCar[0][0], OriCar[0][1], OriCar[0][2], OriCar[1][0], OriCar[1][1], OriCar[1][2], OriCar[2][0], OriCar[2][1], OriCar[2][2])
    print(stupid)
    # Serialize data
    Data = pickle.dumps(stupid)
     
    # Send Data to client
    GameLogic.sServer.sendto(Data, (Host, 10001))
开发者ID:usama-ghufran,项目名称:steerQuest,代码行数:36,代码来源:sheep_client.py

示例8: onMouse

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def onMouse():
    Rasterizer.showMouse(True)
    cont = GameLogic.getCurrentController()
    mouse = cont.sensors["Mouse"]
    over = cont.sensors["Over"]

    if mouse.positive:
        hit = over.hitObject

        if hit is None: 
            return
        
        print(hit.name)
        print(hit.children)

        if hit.name in buildings:
            deselectAll()
            hit.children["Base01.Selected"].setVisible(True)
            infoPanelShow(hit)
            addUnit()
        else:
            if hit.name in units:
                deselectAll()
                hit.children["Unit0.Selected"].setVisible(True)
                cont.owner["selected"] = hit["id"]
                infoPanelShow(hit)
            else:
                for target in scene.objects:
                    if "Target" in target.name and target["id"] == cont.owner["selected"]:
                        target.localPosition = over.hitPosition
开发者ID:griusfux,项目名称:cyber-world,代码行数:32,代码来源:Main.py

示例9: init

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def init(contr):
    """ General initialization of MORSE

    Here, all components, modifiers and middleware are initialized.
    """

    init_logging()

    if MULTINODE_SUPPORT:
        # Configuration for the multi-node simulation
        try:
            node_name = scene_config.node_config["node_name"]
            server_address = scene_config.node_config["server_address"]
            server_port = scene_config.node_config["server_port"]
        except (NameError, AttributeError) as detail:
            logger.warning("No node configuration found. Using default values for this simulation node.\n\tException: ", detail)
            node_name = "temp_name"
            server_address = "localhost"
            server_port = 65000
        GameLogic.node_instance = morse.core.multinode.SimulationNodeClass(node_name, server_address, server_port)


    logger.log(SECTION, 'PRE-INITIALIZATION')
    # Get the version of Python used
    # This is used to determine also the version of Blender
    GameLogic.pythonVersion = sys.version_info
    GameLogic.blenderVersion = bpy.app.version
    logger.info ("Python Version: %s.%s.%s" % GameLogic.pythonVersion[:3])
    logger.info ("Blender Version: %s.%s.%s" % GameLogic.blenderVersion)

    GameLogic.morse_initialised = False
    GameLogic.base_clock = time.clock()
    GameLogic.current_time = 0.0
    # Variable to keep trac of the camera being used
    GameLogic.current_camera_index = 0
    init_ok = True


    logger.log(SECTION, 'SUPERVISION SERVICES INITIALIZATION')
    init_ok = init_supervision_services()
    
    logger.log(SECTION, 'SCENE INITIALIZATION')
    init_ok = init_ok and create_dictionaries()
    init_ok = init_ok and add_modifiers()
    init_ok = init_ok and link_middlewares()
    init_ok = init_ok and link_services()
    init_ok = init_ok and load_overlays()

    if init_ok:
        logger.log(ENDSECTION, 'SCENE INITIALIZED')
        check_dictionaries()
        GameLogic.morse_initialised = True
    else:
        logger.critical('INITIALIZATION FAILED!')
        logger.info("Exiting now.")
        contr = GameLogic.getCurrentController()
        close_all(contr)
        quit(contr)
开发者ID:peterroelants,项目名称:morse,代码行数:60,代码来源:main.py

示例10: reset_objects

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def reset_objects():
    """ Restore all simulation objects to their original position

    Upon receiving the request using sockets, call the
    'reset_objects' function located in morse/blender/main.py
    """
    contr = GameLogic.getCurrentController()
    main_reset(contr)
    return "Objects restored to initial position"
开发者ID:peterroelants,项目名称:morse,代码行数:11,代码来源:supervision_services.py

示例11: switchScene

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def switchScene():
	G.loc = "1"

	if G.menuState == "car":
		G.UIScene.active_camera = G.UIScene.objects["OBCameraCar"]
	elif G.menuState == "loc":
		G.UIScene.active_camera = G.UIScene.objects["OBCameraLoc"]
	else:
		cont = G.getCurrentController()
		cont.actuators["load"].fileName = G.loc+".blend"
		cont.activate("load")
开发者ID:VScalia,项目名称:RadishZombies,代码行数:13,代码来源:jeep+physics+control.py

示例12: main

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def main():
    # Set init
    ip = '127.0.0.1'  ### escucha a routerOSC.pd
    port = 8888
    data = 0
    # Get controller and owner
    controller = GameLogic.getCurrentController()
    owner = controller.owner
        # Connect Blender only one time
    if not owner['connected']:
        
        owner['connected'] = True
        print ("Blender Connected Ori")
     
        GameLogic.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        GameLogic.socket.bind((ip, port))
        GameLogic.socket.setblocking(0)
        GameLogic.socket.settimeout(0.02)
     
    # If Blender connected, get osc 
    else:
        # Get hand wii osc from pd
        
        data = receive_osc(data, port)
        if data != 0:
            d = OSC.decodeOSC(data)
            print(d)
            '''if d[2][8] == "/ori":
                ori,ox,oz =d[2][9], d[2][10], d[2][11]
                scn = bge.logic.getCurrentScene()
                player = scn.objects["player"]
                player['ori'] = ori
                
            if d[2][12] == "/norte":
                nx,ny =d[2][13],d[2][14]
                scn = bge.logic.getCurrentScene()
                player = scn.objects["player"]
                player['tracker_n'] = nx,ny
            
            # solo si hay 2 kinects!!!!!!
            if d[2][15] == "/sur":
                sx,sy =d[2][16],d[2][17]
                scn = bge.logic.getCurrentScene()
                player = scn.objects["player"]
                player['tracker_s'] = sx,sy '''
                
            if d[0] == "/norte":
                nx,ny =d[2],d[3]
                print(nx,ny)
                scn = bge.logic.getCurrentScene()
                player = scn.objects["player"]
                player['tracker_n'] = nx,ny
                          
开发者ID:husk00,项目名称:audiogames,代码行数:54,代码来源:readOSCori.py

示例13: addCredit

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def addCredit():
	## setup aliases
	cont = G.getCurrentController()
	add = cont.actuators["add"]
	own = cont.owner

	## add a sequence of objects, then repeat
	add.object = str(own["counter"])
	cont.activate(add)
	own["counter"] += 1
	if own["counter"] > 10:
		own["counter"] = 0
开发者ID:VScalia,项目名称:RadishZombies,代码行数:14,代码来源:jeep+physics+control.py

示例14: init

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def init(contr):
    """ General initialization of MORSE

    Here, all components, modifiers and middleware are initialized.
    """

    init_logging()

    logger.log(SECTION, "PRE-INITIALIZATION")
    # Get the version of Python used
    # This is used to determine also the version of Blender
    GameLogic.pythonVersion = sys.version_info
    GameLogic.blenderVersion = bpy.app.version
    logger.info("Python Version: %s.%s.%s" % GameLogic.pythonVersion[:3])
    logger.info("Blender Version: %s.%s.%s" % GameLogic.blenderVersion)

    GameLogic.morse_initialised = False
    GameLogic.base_clock = time.clock()
    GameLogic.current_time = 0.0
    # Variable to keep trac of the camera being used
    GameLogic.current_camera_index = 0
    init_ok = True

    logger.log(SECTION, "SUPERVISION SERVICES INITIALIZATION")
    init_ok = init_supervision_services()

    logger.log(SECTION, "SCENE INITIALIZATION")
    init_ok = init_ok and create_dictionaries()
    init_ok = init_ok and link_services()
    init_ok = init_ok and add_modifiers()
    init_ok = init_ok and link_middlewares()
    init_ok = init_ok and load_overlays()

    if init_ok:
        logger.log(ENDSECTION, "SCENE INITIALIZED")
        check_dictionaries()
        GameLogic.morse_initialised = True
    else:
        logger.critical("INITIALIZATION FAILED!")
        logger.info("Exiting now.")
        contr = GameLogic.getCurrentController()
        close_all(contr)
        quit(contr)

    if MULTINODE_SUPPORT:
        init_multinode()
开发者ID:nttputus,项目名称:morse,代码行数:48,代码来源:main.py

示例15: main

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import getCurrentController [as 别名]
def main():
    if GameLogic.Object['closed']:
        return
    else:

        gu.keep_conn([conn1, conn2])
        controller = GameLogic.getCurrentController()
        obj = controller.owner
        ori = obj.localOrientation
        pos = obj.localPosition
        
        if conn1 is not None:
            t1, dt1, x1, y1 = gu.read32(conn1)
            t2, dt2, x2, y2 = gu.read32(conn2)
        else:
            t1, dt1, x1, y1 = np.array([0,]), np.array([0,]), np.array([0,]), np.array([0,])
            t2, dt2, x2, y2 = np.array([0,]), np.array([0,]), np.array([0,]), np.array([0,])
    movement(controller, (x1, y1, x2, y2, t1, t2, dt1, dt2))
开发者ID:kemerelab,项目名称:VR_Ball,代码行数:20,代码来源:test_c.py


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