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

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