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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. resume = scene.objects["resume"]
  92. settings = scene.objects["settings"]
  93. level = scene.objects["level"]
  94. levelselect = scene.objects["levelselect"]
  95. restart = scene.objects["restart"]
  96. exit = scene.objects["exit"]
  97. submenu_on = own["submenu_on"]
  98. level_text = scene.objects["level_text"]
  99. level_text.resolution = 8
  100. lastup = own["lastup"]
  101. lastdown = own["lastdown"]
  102. lastleft = own["lastleft"]
  103. lastright = own["lastright"]
  104. lastpstate = own["lastpstate"]
  105. playspeed = 2
  106. #sSelect = cont.actuators["sSelect"]
  107. cont.deactivate(own.actuators['restart'])
  108. #joy down
  109. if down == 1 and lastdown != 1:
  110. #own.stopAction(0)
  111. pstate = own["pstate"]
  112. if pstate == 0 and submenu_on == 0:
  113. resume.playAction("p_resume", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  114. if pstate == 1 and submenu_on == 0:
  115. settings.playAction("p_settings", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  116. if pstate == 2 and submenu_on == 0:
  117. level.playAction("p_level", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  118. #level.playAction("p_level_select", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  119. if pstate == 3 and submenu_on == 0:
  120. restart.playAction("p_restart", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  121. if pstate == 4 and submenu_on == 0:
  122. exit.playAction("p_exit", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
  123. if pstate < 4 and submenu_on == 0:
  124. own["pstate"] = own["pstate"] + 1
  125. if pstate == 4 and submenu_on == 0:
  126. own["pstate"] = 0
  127. pstate = own["pstate"]
  128. #print(pstate)
  129. cont.activate(own.actuators['sSelect'])
  130. #joy up
  131. if up == 1 and lastup != 1:
  132. pstate = own["pstate"]
  133. if pstate == 0 and submenu_on == 0:
  134. resume.playAction("p_resume", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
  135. if pstate == 1 and submenu_on == 0:
  136. settings.playAction("p_settings", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
  137. if pstate == 2 and submenu_on == 0:
  138. level.playAction("p_level", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
  139. if pstate == 3 and submenu_on == 0:
  140. restart.playAction("p_restart", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
  141. if pstate == 4 and submenu_on == 0:
  142. exit.playAction("p_exit", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
  143. if pstate > 0 and submenu_on == 0:
  144. own["pstate"] = own["pstate"] - 1
  145. if pstate == 0 and submenu_on == 0:
  146. own["pstate"] = 4
  147. pstate = own["pstate"]
  148. #print(pstate)
  149. cont.activate(own.actuators['sSelect'])
  150. if right == 1 and lastright !=1:
  151. cont.activate(own.actuators['sSelect'])
  152. if left == 1 and lastleft != 1:
  153. cont.activate(own.actuators['sSelect'])
  154. #level*****************************************************
  155. if own["submenu"] == "level":
  156. #print("submenu is level")
  157. active_level_select = own["active_level_select"]
  158. import Settings
  159. if left == 1 and lastleft != 1:
  160. if active_level_select >= 0:
  161. active_level_select -= 1
  162. if active_level_select < 0:
  163. active_level_select = 8
  164. #if active_level_select == -1:
  165. #active_level_select = 0
  166. #print(active_level_select)
  167. #move up
  168. #play up
  169. if right == 1 and lastright != 1:
  170. if active_level_select < 9:
  171. active_level_select += 1
  172. if active_level_select == 9:
  173. active_level_select = 0
  174. if active_level_select == -1:
  175. active_level_select = 0
  176. print(active_level_select)
  177. #move down
  178. #play down
  179. if active_level_select == 0:
  180. level_text.text = "Empty Lot"
  181. if active_level_select == 1:
  182. level_text.text = "Waterfall"
  183. if active_level_select == 2:
  184. level_text.text = "Warehouse"
  185. if active_level_select == 3:
  186. level_text.text = "City"
  187. if active_level_select == 4:
  188. level_text.text = "Training"
  189. if active_level_select == 5:
  190. level_text.text = "Spine"
  191. if active_level_select == 6:
  192. level_text.text = "Apricot Park"
  193. if active_level_select == 7:
  194. level_text.text = "Waiting Room"
  195. if active_level_select == 8:
  196. level_text.text = "8 (n/a)"
  197. own["active_level_select"] = active_level_select
  198. #indoor
  199. if aBut == False and active_level_select == 0 and lasta == 1:
  200. level_text.text = ""
  201. cont.activate(own.actuators['loading'])
  202. level = "lot"
  203. main_empty["level"] = "lot"
  204. own["level"] = level
  205. Settings.writeSettings()
  206. print("not")
  207. Settings.readSettings()
  208. cont.activate(own.actuators['restart'])
  209. #Settings.loadlevel()
  210. else:
  211. cont.deactivate(own.actuators['restart'])
  212. #woodbowl
  213. if aBut == False and active_level_select == 1 and lasta == 1:
  214. level_text.text = ""
  215. cont.activate(own.actuators['loading'])
  216. level = "mini_scene"
  217. main_empty["level"] = "mini_scene"
  218. own["level"] = level
  219. Settings.writeSettings()
  220. Settings.readSettings()
  221. cont.activate(own.actuators['restart'])
  222. #Settings.loadlevel()
  223. else: cont.deactivate(own.actuators['restart'])
  224. #mini
  225. if aBut == False and active_level_select == 2 and lasta == 1:
  226. level_text.text = ""
  227. cont.activate(own.actuators['loading'])
  228. level = "warehouse"
  229. main_empty["level"] = "warehouse"
  230. own["level"] = level
  231. Settings.writeSettings()
  232. Settings.readSettings()
  233. cont.activate(own.actuators['restart'])
  234. #Settings.loadlevel()
  235. else: cont.deactivate(own.actuators['restart'])
  236. #level3
  237. if aBut == False and active_level_select == 3 and lasta == 1:
  238. level_text.text = ""
  239. level = "level3"
  240. main_empty["level"] = "city2"
  241. own["level"] = level
  242. Settings.writeSettings()
  243. Settings.readSettings()
  244. cont.activate(own.actuators['restart'])
  245. #Settings.loadlevel()
  246. else: cont.deactivate(own.actuators['restart'])
  247. #hubbas rail
  248. if aBut == False and active_level_select == 4 and lasta == 1:
  249. level_text.text = ""
  250. level = "train"
  251. main_empty["level"] = "train"
  252. own["level"] = level
  253. Settings.writeSettings()
  254. Settings.readSettings()
  255. cont.activate(own.actuators['restart'])
  256. #Settings.loadlevel()
  257. else: cont.deactivate(own.actuators['restart'])
  258. #training
  259. if aBut == False and active_level_select == 5 and lasta == 1:
  260. level_text.text = ""
  261. level = "level3"
  262. main_empty["level"] = "spine"
  263. own["level"] = level
  264. Settings.writeSettings()
  265. Settings.readSettings()
  266. cont.activate(own.actuators['restart'])
  267. #Settings.loadlevel()
  268. else: cont.deactivate(own.actuators['restart'])
  269. if aBut == False and active_level_select == 6 and lasta == 1:
  270. level_text.text = ""
  271. level = "gt"
  272. main_empty["level"] = "gt"
  273. own["level"] = level
  274. Settings.writeSettings()
  275. Settings.readSettings()
  276. cont.activate(own.actuators['restart'])
  277. #Settings.loadlevel()
  278. else: cont.deactivate(own.actuators['restart'])
  279. if aBut == False and active_level_select == 7 and lasta == 1:
  280. level_text.text = ""
  281. level = "store"
  282. main_empty["level"] = "store"
  283. own["level"] = level
  284. Settings.writeSettings()
  285. Settings.readSettings()
  286. cont.activate(own.actuators['restart'])
  287. #Settings.loadlevel()
  288. else: cont.deactivate(own.actuators['restart'])
  289. if aBut == False and active_level_select == 8 and lasta == 1:
  290. level_text.text = ""
  291. level = "level3"
  292. main_empty["level"] = "spine"
  293. own["level"] = level
  294. Settings.writeSettings()
  295. Settings.readSettings()
  296. cont.activate(own.actuators['restart'])
  297. #Settings.loadlevel()
  298. else: cont.deactivate(own.actuators['restart'])
  299. else:
  300. own["active_level_select"] = -1
  301. if bBut == True:
  302. levelselect.playAction("p_level_select", 10,0, layer=3, priority=0, play_mode=0, speed=playspeed)
  303. #**********************************************************
  304. if bBut == 1:
  305. cont.activate(own.actuators['sBack'])
  306. #cont.activate(own.actuators['exit'])
  307. print("bbut")
  308. #go to level submenu
  309. if aBut == True and pstate == 2:
  310. cont.activate(own.actuators['sEnter'])
  311. #cont.activate(own.actuators['quit'])
  312. #print("level")
  313. own["submenu_on"] = 1
  314. own["submenu"] = "level"
  315. level_text.text = "<choose>"
  316. levelselect.playAction("p_level_select", -10,10, layer=3, priority=0, play_mode=0, speed=playspeed)
  317. #exit submenu
  318. if bBut and submenu_on == 1:
  319. own["submenu_on"] = 0
  320. own["submenu"] = None
  321. level_text.text = ""
  322. #exit
  323. if aBut == 1 and pstate == 4:
  324. cont.activate(own.actuators['sEnter'])
  325. cont.activate(own.actuators['quit'])
  326. print("bbut")
  327. if pstate == 0 and submenu_on == 0 and lastpstate != 0:
  328. resume.playAction("p_resume", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  329. if pstate == 1 and submenu_on == 0 and lastpstate != 1:
  330. settings.playAction("p_settings", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  331. if pstate == 2 and submenu_on == 0 and lastpstate != 2:
  332. level.playAction("p_level", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  333. #level.playAction("p_level_select", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  334. if pstate == 3 and submenu_on == 0 and lastpstate != 3:
  335. restart.playAction("p_restart", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  336. if pstate == 4 and submenu_on == 0 and lastpstate != 4:
  337. exit.playAction("p_exit", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
  338. #find the scene and object
  339. scenes = bge.logic.getSceneList()
  340. for scene in scenes :
  341. #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':
  342. #if scene.name == main_empty["level"]:
  343. if scene.name == 'lot':
  344. #print("*****stop sounds")
  345. cc = scene.objects['control_cube.002']
  346. cc.actuators["sroll"].volume = .0001
  347. #cc.deactivate(own.actuators["sroll"])
  348. cc.actuators["sroll"].stopSound()
  349. #print(pstate)
  350. own["lastup"] = up
  351. own["lastdown"] = down
  352. own["lastleft"] = left
  353. own["lastright"] = right
  354. own["lasta"] = aBut
  355. own["lastpstate"] = own["pstate"]
  356. main()