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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import bge
  2. import menuV3
  3. import Settings
  4. #replay huds:
  5. #add_hud
  6. #remove_hud (on control_cube)
  7. def main(cont):
  8. #cont = bge.logic.getCurrentController()
  9. scene = bge.logic.getCurrentScene()
  10. dict = bge.logic.globalDict
  11. skater = scene.objects["Char4"]
  12. deck = scene.objects["b_deck"]
  13. trucks = scene.objects["b_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) or dict['kb_en'] == 1:
  50. if pause_state == 0:
  51. pause_state = 1
  52. else:
  53. pause_state = 0
  54. dict['npause'] = pause_state
  55. print('switching pause state')
  56. #enter pause
  57. if pause_state == 1 and last_pause == 0:
  58. print('entering pause')
  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. cont.activate(cont.actuators['remove_stance'])
  66. cube['camera'] = 2
  67. cube['camnum'] = 2
  68. scene.active_camera = freecam
  69. freecam.lens = mcam['focal_length']
  70. freecam.worldPosition = mcam.worldPosition
  71. freecam.worldOrientation = mcam.worldOrientation
  72. if pause_state == 1:
  73. if mcam['playback'] == False:
  74. layer = 2
  75. if skater.isPlayingAction(layer):
  76. skater.stopAction(layer)
  77. if deck.isPlayingAction(layer):
  78. deck.stopAction(layer)
  79. if trucks.isPlayingAction(layer):
  80. trucks.stopAction(layer)
  81. layer = 3
  82. if skater.isPlayingAction(layer):
  83. skater.stopAction(layer)
  84. if deck.isPlayingAction(layer):
  85. deck.stopAction(layer)
  86. if trucks.isPlayingAction(layer):
  87. trucks.stopAction(layer)
  88. layer = 4
  89. if skater.isPlayingAction(layer):
  90. skater.stopAction(layer)
  91. if deck.isPlayingAction(layer):
  92. deck.stopAction(layer)
  93. if trucks.isPlayingAction(layer):
  94. trucks.stopAction(layer)
  95. menuV3.main(cont)
  96. #exit pause
  97. if pause_state == 0 and last_pause == 1:
  98. Settings.writeSettings()
  99. Settings.writeChar()
  100. own.restoreDynamics()
  101. if own['walk'] == False:
  102. cont.activate(cont.actuators['roll'])
  103. else:
  104. cont.activate(cont.actuators['walk'])
  105. try:
  106. if own['walk'] == False:
  107. own.setLinearVelocity(own['pre_pause_linvel'], 1)
  108. except:
  109. pass
  110. cont.activate(cont.actuators['remove_overlay'])
  111. cont.activate(cont.actuators['add_stance'])
  112. if pause_state == 1 and dict['rtsBut'] == False and dict['last_rtsBut'] == True:
  113. scenes = bge.logic.getSceneList()
  114. if 'pause' in scenes:
  115. cont.activate(cont.actuators['remove_overlay'])
  116. else:
  117. cont.activate(cont.actuators['add_overlay'])
  118. dict['last_npause'] = pause_state
  119. #