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_tmp.py 4.4KB

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