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 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import bge
  2. def main():
  3. cont = bge.logic.getCurrentController()
  4. scene = bge.logic.getCurrentScene()
  5. own = cont.owner
  6. dict = bge.logic.globalDict
  7. skater = scene.objects["Char4"]
  8. deck = scene.objects["deck"]
  9. trucks = scene.objects["trucks"]
  10. try:
  11. pause_state = dict['npause']
  12. last_pause = dict['last_npause']
  13. except:
  14. dict['npause'] = 0
  15. dict['last_npause'] = 0
  16. pause_state = 0
  17. last_pause = 0
  18. def printplaying():
  19. splaying_layers = "S: "
  20. playing_layers = "D: "
  21. tplaying_layers = "T: "
  22. for x in range(1000):
  23. if skater.isPlayingAction(x):
  24. #if trucks.isPlayingAction(x):
  25. #if skater.isPlayingAction(x):
  26. splaying_layers += str(x)
  27. splaying_layers += " "
  28. if deck.isPlayingAction(x):
  29. #if trucks.isPlayingAction(x):
  30. #if skater.isPlayingAction(x):
  31. playing_layers += str(x)
  32. playing_layers += " "
  33. if trucks.isPlayingAction(x):
  34. #if trucks.isPlayingAction(x):
  35. #if skater.isPlayingAction(x):
  36. tplaying_layers += str(x)
  37. tplaying_layers += " "
  38. print(splaying_layers, playing_layers, tplaying_layers)
  39. #switch pause state
  40. if dict['stBut'] == True and dict['last_stBut'] == False:
  41. if pause_state == 0:
  42. pause_state = 1
  43. else:
  44. pause_state = 0
  45. dict['npause'] = pause_state
  46. #enter pause
  47. if pause_state == 1 and last_pause == 0:
  48. own.suspendDynamics()
  49. own['pre_pause_linvel'] = [own['linvelx'], own['linVely'], 0]
  50. own.setLinearVelocity([0,0,0],1)
  51. cont.activate(cont.actuators['empty'])
  52. cont.activate(cont.actuators['add_overlay'])
  53. printplaying()
  54. if pause_state == 1:
  55. layer = 450
  56. if skater.isPlayingAction(layer):
  57. skater.stopAction(layer)
  58. if deck.isPlayingAction(layer):
  59. deck.stopAction(layer)
  60. if trucks.isPlayingAction(layer):
  61. trucks.stopAction(layer)
  62. layer = 460
  63. if skater.isPlayingAction(layer):
  64. skater.stopAction(layer)
  65. if deck.isPlayingAction(layer):
  66. deck.stopAction(layer)
  67. if trucks.isPlayingAction(layer):
  68. trucks.stopAction(layer)
  69. layer = 470
  70. if skater.isPlayingAction(layer):
  71. skater.stopAction(layer)
  72. if deck.isPlayingAction(layer):
  73. deck.stopAction(layer)
  74. if trucks.isPlayingAction(layer):
  75. trucks.stopAction(layer)
  76. #exit pause
  77. if pause_state == 0 and last_pause == 1:
  78. #print("unpause")
  79. own.restoreDynamics()
  80. #own.setlinearVelocity([0,0,0],1]
  81. cont.activate(cont.actuators['roll'])
  82. #print("pre_pause_linvel = ", own['pre_pause_linvel'])
  83. try:
  84. own.setLinearVelocity(own['pre_pause_linvel'], 1)
  85. except:
  86. pass
  87. cont.activate(cont.actuators['remove_overlay'])
  88. #print(pause_state)
  89. dict['last_npause'] = pause_state
  90. main()