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.

joytimers.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #joytimers.py
  2. import bge
  3. countdown = 20
  4. def main(own):
  5. class stick:
  6. def __init__(self, ud, lr):
  7. self.q1 = 0
  8. self.q2 = 0
  9. self.q3 = 0
  10. self.q4 = 0
  11. self.q5 = 0
  12. self.q6 = 0
  13. self.q7 = 0
  14. self.q8 = 0
  15. self.ud = ud
  16. self.lr = lr
  17. self.qs = ['q6', 'q8', 'q2', 'q4', 'q5', 'q1', 'q3', 'q7']
  18. def reset(self):
  19. self.q1 = 0
  20. self.q2 = 0
  21. self.q3 = 0
  22. self.q4 = 0
  23. self.q5 = 0
  24. self.q6 = 0
  25. self.q7 = 0
  26. self.q8 = 0
  27. def update(self):
  28. dict = bge.logic.globalDict
  29. def q6():
  30. if dict[self.ud] > .04 and dict[self.lr] < -0.04:
  31. return countdown
  32. def q8():
  33. if dict[self.ud] < -.04 and dict[self.lr] < -0.04:
  34. return countdown
  35. def q2():
  36. if dict[self.ud] < -.04 and dict[self.lr] > 0.04:
  37. return countdown
  38. def q4():
  39. if dict[self.ud] > .04 and dict[self.lr] > 0.04:
  40. return countdown
  41. def q5():
  42. if dict[self.ud] > .07 and self.q4 is not countdown and self.q6 is not countdown:
  43. return countdown
  44. def q1():
  45. if dict[self.ud] < -.07 and self.q8 is not countdown and self.q2 is not countdown:
  46. return countdown
  47. def q3():
  48. if dict[self.lr] > .07 and self.q2 is not countdown and self.q4 is not countdown:
  49. return countdown
  50. def q7():
  51. if dict[self.lr] < -.07 and self.q6 is not countdown and self.q8 is not countdown:
  52. return countdown
  53. for cur_q in self.qs:
  54. val = getattr(self, cur_q)
  55. v2 = locals()[cur_q]()
  56. if v2 is not None:
  57. setattr(self, cur_q, v2)
  58. elif val > 0:
  59. setattr(self, cur_q, val - 1)
  60. if 'jt_inited' not in own:
  61. own['jt_inited'] = True
  62. own['jsl'] = stick('lUD', 'lLR')
  63. own['jsr'] = stick('rUD', 'rLR')
  64. own['jsl'].update()
  65. own['jsr'].update()