Shuvit game master repo. http://shuvit.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

npause.py 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import bge
  2. import menuV3
  3. import Settings
  4. #replay huds:
  5. #add_hud
  6. #remove_hud (on control_cube)
  7. def main():
  8. cont = bge.logic.getCurrentController()
  9. scene = bge.logic.getCurrentScene()
  10. #own = cont.owner
  11. dictionary = bge.logic.globalDict
  12. skater = scene.objects["Char4"]
  13. deck = scene.objects["deck"]
  14. trucks = scene.objects["trucks"]
  15. own = scene.objects["control_cube.002"]
  16. camList = scene.cameras
  17. freecam = camList["freecam"]
  18. mcam = camList['Camera.003']
  19. #freecam = scene.objects['freecam']
  20. cube = scene.objects['control_cube.002']
  21. pause_state = dictionary['npause']
  22. last_pause = dictionary['last_npause']
  23. def printplaying():
  24. splaying_layers = "S: "
  25. playing_layers = "D: "
  26. tplaying_layers = "T: "
  27. for x in range(1000):
  28. if skater.isPlayingAction(x):
  29. #if trucks.isPlayingAction(x):
  30. #if skater.isPlayingAction(x):
  31. splaying_layers += str(x)
  32. splaying_layers += " "
  33. if deck.isPlayingAction(x):
  34. #if trucks.isPlayingAction(x):
  35. #if skater.isPlayingAction(x):
  36. playing_layers += str(x)
  37. playing_layers += " "
  38. if trucks.isPlayingAction(x):
  39. #if trucks.isPlayingAction(x):
  40. #if skater.isPlayingAction(x):
  41. tplaying_layers += str(x)
  42. tplaying_layers += " "
  43. print(splaying_layers, playing_layers, tplaying_layers)
  44. #switch pause state
  45. if dictionary['stBut'] == True and dictionary['last_stBut'] == False:
  46. if pause_state == False:
  47. pause_state = True
  48. else:
  49. pause_state = False
  50. dictionary['npause'] = pause_state
  51. #enter pause
  52. if pause_state == True and last_pause == False:
  53. own.suspendDynamics()
  54. own['pre_pause_linvel'] = [own['linvelx'], own['linVely'], 0]
  55. own.setLinearVelocity([0,0,0],1)
  56. cont.activate(cont.actuators['empty'])
  57. if mcam['playback'] == False:
  58. cont.activate(cont.actuators['add_overlay'])
  59. #pass
  60. #printplaying()
  61. cont.activate(cont.actuators['remove_stance'])
  62. cube['camera'] = 2
  63. cube['camnum'] = 2
  64. scene.active_camera = freecam
  65. #print('set freecam', scene.active_camera)
  66. freecam.lens = mcam['focal_length']
  67. freecam.worldPosition = mcam.worldPosition
  68. freecam.worldOrientation = mcam.worldOrientation
  69. if pause_state == True:
  70. if mcam['playback'] == False:
  71. layer = 2
  72. if skater.isPlayingAction(layer):
  73. skater.stopAction(layer)
  74. if deck.isPlayingAction(layer):
  75. deck.stopAction(layer)
  76. if trucks.isPlayingAction(layer):
  77. trucks.stopAction(layer)
  78. layer = 3
  79. if skater.isPlayingAction(layer):
  80. skater.stopAction(layer)
  81. if deck.isPlayingAction(layer):
  82. deck.stopAction(layer)
  83. if trucks.isPlayingAction(layer):
  84. trucks.stopAction(layer)
  85. layer = 4
  86. if skater.isPlayingAction(layer):
  87. skater.stopAction(layer)
  88. if deck.isPlayingAction(layer):
  89. deck.stopAction(layer)
  90. if trucks.isPlayingAction(layer):
  91. trucks.stopAction(layer)
  92. menuV3.main(cont)
  93. #exit pause
  94. if pause_state == False and last_pause == True:
  95. #print("unpause")
  96. Settings.writeSettings()
  97. own.restoreDynamics()
  98. #own['camera'] = 0
  99. #own.setlinearVelocity([0,0,0],1]
  100. if own['walk'] == False:
  101. cont.activate(cont.actuators['roll'])
  102. else:
  103. cont.activate(cont.actuators['walk'])
  104. #print("pre_pause_linvel = ", own['pre_pause_linvel'])
  105. try:
  106. own.setLinearVelocity(own['pre_pause_linvel'], 1)
  107. except:
  108. pass
  109. cont.activate(cont.actuators['remove_overlay'])
  110. cont.activate(cont.actuators['add_stance'])
  111. if pause_state == True and dictionary['rtsBut'] == False and dictionary['last_rtsBut'] == True:
  112. scenes = bge.logic.getSceneList()
  113. if 'pause' in scenes:
  114. cont.activate(cont.actuators['remove_overlay'])
  115. else:
  116. cont.activate(cont.actuators['add_overlay'])
  117. #print(pause_state)
  118. dictionary['last_npause'] = pause_state
  119. #print(scene.active_camera, cube['camera'])
  120. main()