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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. dict = 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. try:
  22. pause_state = dict['npause']
  23. last_pause = dict['last_npause']
  24. except:
  25. dict['npause'] = 0
  26. dict['last_npause'] = 0
  27. pause_state = 0
  28. last_pause = 0
  29. def printplaying():
  30. splaying_layers = "S: "
  31. playing_layers = "D: "
  32. tplaying_layers = "T: "
  33. for x in range(1000):
  34. if skater.isPlayingAction(x):
  35. #if trucks.isPlayingAction(x):
  36. #if skater.isPlayingAction(x):
  37. splaying_layers += str(x)
  38. splaying_layers += " "
  39. if deck.isPlayingAction(x):
  40. #if trucks.isPlayingAction(x):
  41. #if skater.isPlayingAction(x):
  42. playing_layers += str(x)
  43. playing_layers += " "
  44. if trucks.isPlayingAction(x):
  45. #if trucks.isPlayingAction(x):
  46. #if skater.isPlayingAction(x):
  47. tplaying_layers += str(x)
  48. tplaying_layers += " "
  49. print(splaying_layers, playing_layers, tplaying_layers)
  50. #switch pause state
  51. if dict['stBut'] == True and dict['last_stBut'] == False:
  52. if pause_state == 0:
  53. pause_state = 1
  54. else:
  55. pause_state = 0
  56. dict['npause'] = pause_state
  57. #enter pause
  58. if pause_state == 1 and last_pause == 0:
  59. own.suspendDynamics()
  60. own['pre_pause_linvel'] = [own['linvelx'], own['linVely'], 0]
  61. own.setLinearVelocity([0,0,0],1)
  62. cont.activate(cont.actuators['empty'])
  63. if mcam['playback'] == False:
  64. cont.activate(cont.actuators['add_overlay'])
  65. #pass
  66. #printplaying()
  67. cont.activate(cont.actuators['remove_stance'])
  68. cube['camera'] = 2
  69. cube['camnum'] = 2
  70. scene.active_camera = freecam
  71. #print('set freecam', scene.active_camera)
  72. freecam.lens = mcam['focal_length']
  73. freecam.worldPosition = mcam.worldPosition
  74. freecam.worldOrientation = mcam.worldOrientation
  75. if pause_state == 1:
  76. if mcam['playback'] == False:
  77. layer = 2
  78. if skater.isPlayingAction(layer):
  79. skater.stopAction(layer)
  80. if deck.isPlayingAction(layer):
  81. deck.stopAction(layer)
  82. if trucks.isPlayingAction(layer):
  83. trucks.stopAction(layer)
  84. layer = 3
  85. if skater.isPlayingAction(layer):
  86. skater.stopAction(layer)
  87. if deck.isPlayingAction(layer):
  88. deck.stopAction(layer)
  89. if trucks.isPlayingAction(layer):
  90. trucks.stopAction(layer)
  91. layer = 4
  92. if skater.isPlayingAction(layer):
  93. skater.stopAction(layer)
  94. if deck.isPlayingAction(layer):
  95. deck.stopAction(layer)
  96. if trucks.isPlayingAction(layer):
  97. trucks.stopAction(layer)
  98. menuV3.main(cont)
  99. #exit pause
  100. if pause_state == 0 and last_pause == 1:
  101. #print("unpause")
  102. Settings.writeSettings()
  103. own.restoreDynamics()
  104. #own['camera'] = 0
  105. #own.setlinearVelocity([0,0,0],1]
  106. if own['walk'] == False:
  107. cont.activate(cont.actuators['roll'])
  108. else:
  109. cont.activate(cont.actuators['walk'])
  110. #print("pre_pause_linvel = ", own['pre_pause_linvel'])
  111. try:
  112. own.setLinearVelocity(own['pre_pause_linvel'], 1)
  113. except:
  114. pass
  115. cont.activate(cont.actuators['remove_overlay'])
  116. cont.activate(cont.actuators['add_stance'])
  117. if pause_state == 1 and dict['rtsBut'] == False and dict['last_rtsBut'] == True:
  118. scenes = bge.logic.getSceneList()
  119. if 'pause' in scenes:
  120. cont.activate(cont.actuators['remove_overlay'])
  121. else:
  122. cont.activate(cont.actuators['add_overlay'])
  123. #print(pause_state)
  124. dict['last_npause'] = pause_state
  125. #print(scene.active_camera, cube['camera'])
  126. main()