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.

StatesPlayer.py 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import bge
  2. #====================================
  3. State = type("State", (object,), {})
  4. #====================================
  5. class State(object):
  6. def __init__(self, FSM):
  7. self.FSM = FSM
  8. self.timer = 0
  9. self.startTime = 0
  10. def Enter(self):
  11. self.timer = 0
  12. self.startTime = 0
  13. def Execute(self):
  14. print('Executing')
  15. def Exit(self):
  16. print('Exiting')
  17. #====================================
  18. class Example(State):
  19. def __init__(self,FSM):
  20. super(Example, self).__init__(FSM)
  21. def Enter(self):
  22. self.FSM.stateLife = 1
  23. super(Example, self).Enter()
  24. def Execute(self):
  25. self.FSM.stateLife += 1
  26. #self.FSM.ToTransition('toLand')
  27. def Exit(self):
  28. pass
  29. #====================================
  30. class Startup(State):
  31. def __init__(self,FSM):
  32. super(Startup, self).__init__(FSM)
  33. def Enter(self):
  34. self.FSM.stateLife = 1
  35. super(Startup, self).Enter()
  36. def Execute(self):
  37. self.FSM.stateLife += 1
  38. #if self.FSM.stateLife == 2:
  39. #Startup.main(self.FSM.owner['cont'])
  40. self.FSM.ToTransition('toWalk')
  41. print('player FSM')
  42. def Exit(self):
  43. pass
  44. #====================================
  45. class Walk(State):
  46. def __init__(self,FSM):
  47. super(Walk, self).__init__(FSM)
  48. def Enter(self):
  49. self.FSM.stateLife = 1
  50. super(Walk, self).Enter()
  51. def Execute(self):
  52. self.FSM.stateLife += 1
  53. #self.FSM.ToTransition('toLand')
  54. def Exit(self):
  55. pass
  56. #====================================
  57. class Roll(State):
  58. def __init__(self,FSM):
  59. super(Roll, self).__init__(FSM)
  60. def Enter(self):
  61. self.FSM.stateLife = 1
  62. super(Roll, self).Enter()
  63. def Execute(self):
  64. self.FSM.stateLife += 1
  65. #self.FSM.ToTransition('toLand')
  66. def Exit(self):
  67. pass
  68. #====================================