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


Python GameLogic.endGame方法代码示例

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


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

示例1: main

# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import endGame [as 别名]
def main():
    if GameLogic.Object['closed']:
        return
    else:
        # check if time is up
        proceeding = GameLogic.Object['last'] - GameLogic.Object['start']
        if proceeding > GameLogic.Object['duration'] - 0.005:
            GameLogic.Object['closed'] = True
            print(proceeding)
            dropboxdao.upload_file(GameLogic.Object['trial_file'], '/trial.txt')
            dropboxdao.upload_file(GameLogic.Object['trajectory_file'], \
                '/trajectory&event/trajectory_%s.txt'%str(trial_id))
            
            line = '%s %.3f\n' % ('end', GameLogic.Object['last']-GameLogic.Object['start'])
            dropboxdao.update_file(GameLogic.Object['event_file'], line, 'a')
            dropboxdao.upload_file(GameLogic.Object['event_file'], \
                '/trajectory&event/event_%s.txt'%str(trial_id))
            GameLogic.endGame()
        
        
        gu.keep_conn([conn1, conn2])
        controller = GameLogic.getCurrentController()
        obj = controller.owner
        ori = obj.localOrientation
        pos = obj.localPosition
        
        # check timestampe & if inserting trajectory point 
        current_time = time.time()
        if (current_time - GameLogic.Object['last']) > GameLogic.Object['timestamp'] - 0.005:
            GameLogic.Object['last'] = current_time
            line = '%.3f %.3f %.3f %.3f\n' % (pos[0],pos[1],ori[0][0],ori[1][0])
            dropboxdao.update_file(GameLogic.Object['trajectory_file'], line, 'a')
                
        # check if pumping reward
        if arduino:
            last_pos = GameLogic.Object['last_position']
            area = (pos[0] < 0 and -0.1 <= pos[1] <= 0.1)
            last_area = (last_pos[0] < 0 and -0.1 <= last_pos[1] <= 0.1)

            if not area and not last_area and GameLogic.Object['reward_done']:
                GameLogic.Object['reward_done'] = False

            elif area and not last_area:
                print('enter reward area')
                GameLogic.Object['entry_time'] = time.time()
                line = '%s %.3f\n' % ('enter', GameLogic.Object['entry_time'] - GameLogic.Object['start'])
                dropboxdao.update_file(GameLogic.Object['event_file'], line, 'a')
                
            elif not area and last_area:
                print('exit reward area')
                line = '%s %.3f\n' % ('exit', time.time()-GameLogic.Object['start'])
                dropboxdao.update_file(GameLogic.Object['event_file'], line, 'a')
            
            elif area and last_area and not GameLogic.Object['reward_done']:
                GameLogic.Object['stay_time'] = time.time()
                duration = GameLogic.Object['stay_time'] - GameLogic.Object['entry_time']
                if  duration > 2.995:
                    print('reward: %.3f'%duration)
                    arduino.write(b'L')
                    GameLogic.Object['reward_done'] = True
                    line = '%s %.3f\n' % ('reward', GameLogic.Object['stay_time']-GameLogic.Object['start'])
                                              
            
        GameLogic.Object['last_position'] = [pos[0],pos[1]]

        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, (y1, y2, t1, t2, dt1, dt2))
开发者ID:kemerelab,项目名称:VR_Ball,代码行数:75,代码来源:camera_c.py


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