本文整理汇总了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))