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.

pause.py 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. import bge
  2. cont = bge.logic.getCurrentController()
  3. own = cont.owner
  4. os = 'Windows'
  5. from sys import platform
  6. if platform != "win32":
  7. os = 'Linux'
  8. def onWindows():
  9. return os == 'Windows'
  10. reduction = 400000
  11. axisTh = 0.03
  12. #Sensor logic bricks connected to the python Controller
  13. aXis = cont.sensors["sControla"]
  14. bUtt = cont.sensors["sControlb"]
  15. onW = onWindows()
  16. # windows stuff
  17. lar_lts = 0
  18. uad_lts = 1
  19. lt = 4 if onW else 2
  20. lar_rts = 2 if onW else 3
  21. uad_rts = 3 if onW else 4
  22. rt = 5
  23. # These are the numerical values associated with the buttons on the Xbox Controller
  24. # Called with - SensorName.getButtonStatus(buttonnumber) -
  25. # A joystick sensor logic brick (with the 'Button' Event Type; 'All Events' selected; and 'Tap' enabled) must be connected to the Python Controller logic brick to call these buttons
  26. a_but = 0 if onW else 0
  27. b_but = 1 if onW else 1
  28. x_but = 2 if onW else 2
  29. y_but = 3 if onW else 3
  30. l_bump = 9 if onW else 4
  31. r_bump = 10 if onW else 5
  32. bk_but = 4 if onW else 6
  33. st_but = 6 if onW else 7
  34. xb_but = 5 if onW else 8
  35. lts_pr = 7 if onW else 9
  36. rts_pr = 8 if onW else 10
  37. l_dp = 13 if onW else 11
  38. r_dp = 14 if onW else 12
  39. u_dp = 11 if onW else 13
  40. d_dp = 12 if onW else 14
  41. lLR = aXis.axisValues[lar_lts] / reduction
  42. lUD = aXis.axisValues[uad_lts] / reduction
  43. rLR = aXis.axisValues[lar_rts] / reduction
  44. rUD = aXis.axisValues[uad_rts] / reduction
  45. lTrig = aXis.axisValues[lt] / reduction
  46. rTrig = aXis.axisValues[rt] / reduction
  47. aBut = bUtt.getButtonStatus(a_but)
  48. bBut = bUtt.getButtonStatus(b_but)
  49. xBut = bUtt.getButtonStatus(x_but)
  50. yBut = bUtt.getButtonStatus(y_but)
  51. lBump = bUtt.getButtonStatus(l_bump)
  52. rBump = bUtt.getButtonStatus(r_bump)
  53. bkBut = bUtt.getButtonStatus(bk_but)
  54. stBut = bUtt.getButtonStatus(st_but)
  55. xbBut = bUtt.getButtonStatus(xb_but)
  56. ltsBut = bUtt.getButtonStatus(lts_pr)
  57. rtsBut = bUtt.getButtonStatus(rts_pr)
  58. ldPad = bUtt.getButtonStatus(l_dp)
  59. rdPad = bUtt.getButtonStatus(r_dp)
  60. udPad = bUtt.getButtonStatus(u_dp)
  61. ddPad = bUtt.getButtonStatus(d_dp)
  62. #print(lUD)
  63. axis_sens = .06
  64. #print(aBut)
  65. lasta = own["lasta"]
  66. if lUD > axis_sens: down = 1
  67. else: down = 0
  68. if lUD < -axis_sens:
  69. up = 1
  70. #print("up")
  71. else: up = 0
  72. #print(down, up)
  73. if lLR > axis_sens: right = 1
  74. else: right = 0
  75. if lLR < -axis_sens: left = 1
  76. else: left = 0
  77. fileName = "Settings.dat"
  78. scenes = bge.logic.getSceneList()
  79. #print(scenes)
  80. main_scene = [scene for scene in scenes if scene.name=="main"][0]
  81. main_empty = main_scene.objects['Empty']
  82. def main():
  83. cont = bge.logic.getCurrentController()
  84. own = cont.owner
  85. #down = cont.sensors["down"]
  86. #up = cont.sensors["up"]
  87. #bBut = cont.sensors["bBut"]
  88. #aBut = cont.sensors["aBut"]
  89. pstate = own["pstate"]
  90. scene = bge.logic.getCurrentScene()
  91. dict = bge.logic.globalDict
  92. resume = scene.objects["resume"]
  93. settings = scene.objects["settings"]
  94. level = scene.objects["level"]
  95. dict['level'] = level
  96. levelselect = scene.objects["levelselect"]
  97. restart = scene.objects["restart"]
  98. exit = scene.objects["exit"]
  99. submenu_on = own["submenu_on"]
  100. level_text = scene.objects["level_text"]
  101. level_text.resolution = 8
  102. lastup = own["lastup"]
  103. lastdown = own["lastdown"]
  104. lastleft = own["lastleft"]
  105. lastright = own["lastright"]
  106. lastpstate = own["lastpstate"]
  107. playspeed = 2
  108. #sSelect = cont.actuators["sSelect"]
  109. cont.deactivate(own.actuators['restart'])
  110. #joy down
  111. if down == 1 and lastdown != 1:
  112. #own.stopAction(0)
  113. pstate = own["pstate"]
  114. if pstate == 0 and submenu_on == 0:
  115. resume.playAction("p_resume", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  116. if pstate == 1 and submenu_on == 0:
  117. settings.playAction("p_settings", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  118. if pstate == 2 and submenu_on == 0:
  119. level.playAction("p_level", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  120. #level.playAction("p_level_select", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  121. if pstate == 3 and submenu_on == 0:
  122. restart.playAction("p_restart", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  123. if pstate == 4 and submenu_on == 0:
  124. exit.playAction("p_exit", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  125. if pstate < 4 and submenu_on == 0:
  126. own["pstate"] = own["pstate"] + 1
  127. if pstate == 4 and submenu_on == 0:
  128. own["pstate"] = 0
  129. pstate = own["pstate"]
  130. #print(pstate)
  131. cont.activate(own.actuators['sSelect'])
  132. #joy up
  133. if up == 1 and lastup != 1:
  134. pstate = own["pstate"]
  135. if pstate == 0 and submenu_on == 0:
  136. resume.playAction("p_resume", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
  137. if pstate == 1 and submenu_on == 0:
  138. settings.playAction("p_settings", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
  139. if pstate == 2 and submenu_on == 0:
  140. level.playAction("p_level", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
  141. if pstate == 3 and submenu_on == 0:
  142. restart.playAction("p_restart", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
  143. if pstate == 4 and submenu_on == 0:
  144. exit.playAction("p_exit", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
  145. if pstate > 0 and submenu_on == 0:
  146. own["pstate"] = own["pstate"] - 1
  147. if pstate == 0 and submenu_on == 0:
  148. own["pstate"] = 4
  149. pstate = own["pstate"]
  150. #print(pstate)
  151. cont.activate(own.actuators['sSelect'])
  152. if right == 1 and lastright !=1:
  153. cont.activate(own.actuators['sSelect'])
  154. if left == 1 and lastleft != 1:
  155. cont.activate(own.actuators['sSelect'])
  156. #level*****************************************************
  157. if own["submenu"] == "level":
  158. #print("submenu is level")
  159. active_level_select = own["active_level_select"]
  160. import Settings
  161. if left == 1 and lastleft != 1:
  162. if active_level_select >= 0:
  163. active_level_select -= 1
  164. if active_level_select < 0:
  165. active_level_select = 8
  166. #if active_level_select == -1:
  167. #active_level_select = 0
  168. #print(active_level_select)
  169. #move up
  170. #play up
  171. if right == 1 and lastright != 1:
  172. if active_level_select < 9:
  173. active_level_select += 1
  174. if active_level_select == 9:
  175. active_level_select = 0
  176. if active_level_select == -1:
  177. active_level_select = 0
  178. print(active_level_select)
  179. #move down
  180. #play down
  181. if active_level_select == 0:
  182. level_text.text = "Empty Lot"
  183. if active_level_select == 1:
  184. level_text.text = "Waterfall"
  185. if active_level_select == 2:
  186. level_text.text = "Warehouse"
  187. if active_level_select == 3:
  188. level_text.text = "City"
  189. if active_level_select == 4:
  190. level_text.text = "Training"
  191. if active_level_select == 5:
  192. level_text.text = "Spine"
  193. if active_level_select == 6:
  194. level_text.text = "Apricot Park"
  195. if active_level_select == 7:
  196. level_text.text = "Waiting Room"
  197. if active_level_select == 8:
  198. level_text.text = "8 (n/a)"
  199. own["active_level_select"] = active_level_select
  200. #indoor
  201. if aBut == False and active_level_select == 0 and lasta == 1:
  202. level_text.text = ""
  203. cont.activate(own.actuators['loading'])
  204. level = "lot"
  205. main_empty["level"] = "lot"
  206. own["level"] = level
  207. Settings.writeSettings()
  208. print("not")
  209. Settings.readSettings()
  210. cont.activate(own.actuators['restart'])
  211. #Settings.loadlevel()
  212. else:
  213. cont.deactivate(own.actuators['restart'])
  214. #woodbowl
  215. if aBut == False and active_level_select == 1 and lasta == 1:
  216. level_text.text = ""
  217. cont.activate(own.actuators['loading'])
  218. level = "mini_scene"
  219. main_empty["level"] = "mini_scene"
  220. own["level"] = level
  221. Settings.writeSettings()
  222. Settings.readSettings()
  223. cont.activate(own.actuators['restart'])
  224. #Settings.loadlevel()
  225. else: cont.deactivate(own.actuators['restart'])
  226. #mini
  227. if aBut == False and active_level_select == 2 and lasta == 1:
  228. level_text.text = ""
  229. cont.activate(own.actuators['loading'])
  230. level = "warehouse"
  231. main_empty["level"] = "warehouse"
  232. own["level"] = level
  233. Settings.writeSettings()
  234. Settings.readSettings()
  235. cont.activate(own.actuators['restart'])
  236. #Settings.loadlevel()
  237. else: cont.deactivate(own.actuators['restart'])
  238. #level3
  239. if aBut == False and active_level_select == 3 and lasta == 1:
  240. level_text.text = ""
  241. level = "level3"
  242. main_empty["level"] = "city2"
  243. own["level"] = level
  244. Settings.writeSettings()
  245. Settings.readSettings()
  246. cont.activate(own.actuators['restart'])
  247. #Settings.loadlevel()
  248. else: cont.deactivate(own.actuators['restart'])
  249. #hubbas rail
  250. if aBut == False and active_level_select == 4 and lasta == 1:
  251. level_text.text = ""
  252. level = "train"
  253. main_empty["level"] = "train"
  254. own["level"] = level
  255. Settings.writeSettings()
  256. Settings.readSettings()
  257. cont.activate(own.actuators['restart'])
  258. #Settings.loadlevel()
  259. else: cont.deactivate(own.actuators['restart'])
  260. #training
  261. if aBut == False and active_level_select == 5 and lasta == 1:
  262. level_text.text = ""
  263. level = "level3"
  264. main_empty["level"] = "spine"
  265. own["level"] = level
  266. Settings.writeSettings()
  267. Settings.readSettings()
  268. cont.activate(own.actuators['restart'])
  269. #Settings.loadlevel()
  270. else: cont.deactivate(own.actuators['restart'])
  271. if aBut == False and active_level_select == 6 and lasta == 1:
  272. level_text.text = ""
  273. level = "gt"
  274. main_empty["level"] = "gt"
  275. own["level"] = level
  276. Settings.writeSettings()
  277. Settings.readSettings()
  278. cont.activate(own.actuators['restart'])
  279. #Settings.loadlevel()
  280. else: cont.deactivate(own.actuators['restart'])
  281. if aBut == False and active_level_select == 7 and lasta == 1:
  282. level_text.text = ""
  283. level = "store"
  284. main_empty["level"] = "store"
  285. own["level"] = level
  286. Settings.writeSettings()
  287. Settings.readSettings()
  288. cont.activate(own.actuators['restart'])
  289. #Settings.loadlevel()
  290. else: cont.deactivate(own.actuators['restart'])
  291. if aBut == False and active_level_select == 8 and lasta == 1:
  292. level_text.text = ""
  293. level = "level3"
  294. main_empty["level"] = "spine"
  295. own["level"] = level
  296. Settings.writeSettings()
  297. Settings.readSettings()
  298. cont.activate(own.actuators['restart'])
  299. #Settings.loadlevel()
  300. else: cont.deactivate(own.actuators['restart'])
  301. else:
  302. own["active_level_select"] = -1
  303. if bBut == True:
  304. levelselect.playAction("p_level_select", 10,0, layer=3, priority=0, play_mode=0, speed=playspeed)
  305. #**********************************************************
  306. if bBut == 1:
  307. cont.activate(own.actuators['sBack'])
  308. #cont.activate(own.actuators['exit'])
  309. print("bbut")
  310. #go to level submenu
  311. if aBut == True and pstate == 2:
  312. cont.activate(own.actuators['sEnter'])
  313. #cont.activate(own.actuators['quit'])
  314. #print("level")
  315. own["submenu_on"] = 1
  316. own["submenu"] = "level"
  317. level_text.text = "<choose>"
  318. levelselect.playAction("p_level_select", -10,10, layer=3, priority=0, play_mode=0, speed=playspeed)
  319. #exit submenu
  320. if bBut and submenu_on == 1:
  321. own["submenu_on"] = 0
  322. own["submenu"] = None
  323. level_text.text = ""
  324. #exit
  325. if aBut == 1 and pstate == 4:
  326. cont.activate(own.actuators['sEnter'])
  327. cont.activate(own.actuators['quit'])
  328. print("bbut")
  329. if pstate == 0 and submenu_on == 0 and lastpstate != 0:
  330. resume.playAction("p_resume", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  331. if pstate == 1 and submenu_on == 0 and lastpstate != 1:
  332. settings.playAction("p_settings", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  333. if pstate == 2 and submenu_on == 0 and lastpstate != 2:
  334. level.playAction("p_level", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  335. #level.playAction("p_level_select", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  336. if pstate == 3 and submenu_on == 0 and lastpstate != 3:
  337. restart.playAction("p_restart", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  338. if pstate == 4 and submenu_on == 0 and lastpstate != 4:
  339. exit.playAction("p_exit", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  340. #find the scene and object
  341. scenes = bge.logic.getSceneList()
  342. for scene in scenes :
  343. #if scene.name == 'lot' or scene.name == 'train' or scene.name == 'mini_scene' or scene.name == 'city' or scene.name == 'city2' or scene.name == 'spine':
  344. #if scene.name == main_empty["level"]:
  345. if scene.name == 'lot':
  346. #print("*****stop sounds")
  347. cc = scene.objects['control_cube.002']
  348. cc.actuators["sroll"].volume = .0001
  349. #cc.deactivate(own.actuators["sroll"])
  350. cc.actuators["sroll"].stopSound()
  351. #print(pstate)
  352. own["lastup"] = up
  353. own["lastdown"] = down
  354. own["lastleft"] = left
  355. own["lastright"] = right
  356. own["lasta"] = aBut
  357. own["lastpstate"] = own["pstate"]
  358. main()