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.

StatesGame.py 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import bge
  2. import random
  3. import Startup as S2
  4. import Settings
  5. import inputs
  6. import logo_fades
  7. #====================================
  8. State = type("State", (object,), {})
  9. #====================================
  10. class State(object):
  11. def __init__(self, FSM):
  12. self.FSM = FSM
  13. self.timer = 0
  14. self.startTime = 0
  15. def Enter(self):
  16. self.timer = 0
  17. self.startTime = 0
  18. def Execute(self):
  19. print('Executing')
  20. def Exit(self):
  21. print('Exiting')
  22. #====================================
  23. class Example(State):
  24. def __init__(self,FSM):
  25. super(Example, self).__init__(FSM)
  26. def Enter(self):
  27. self.FSM.stateLife = 1
  28. super(Example, self).Enter()
  29. def Execute(self):
  30. self.FSM.stateLife += 1
  31. #self.FSM.ToTransition('toLand')
  32. def Exit(self):
  33. pass
  34. #====================================
  35. class Startup(State):
  36. def __init__(self,FSM):
  37. super(Startup, self).__init__(FSM)
  38. def Enter(self):
  39. self.FSM.stateLife = 1
  40. super(Startup, self).Enter()
  41. def Execute(self):
  42. self.FSM.stateLife += 1
  43. #if self.FSM.stateLife == 2:
  44. #Startup.main(self.FSM.owner['cont'])
  45. self.FSM.ToTransition('toIniter')
  46. def Exit(self):
  47. pass
  48. #====================================
  49. class Initer(State):
  50. def __init__(self,FSM):
  51. super(Initer, self).__init__(FSM)
  52. def Enter(self):
  53. self.FSM.stateLife = 1
  54. super(Initer, self).Enter()
  55. def Execute(self):
  56. self.FSM.stateLife += 1
  57. if self.FSM.stateLife == 2:
  58. print('--------- fsm running startup')
  59. S2.main(self.FSM.owner['cont'])
  60. #Settings.readSettings(self.FSM.owner['cont'])
  61. Settings.readSettings()
  62. Settings.setres()
  63. if self.FSM.stateLife == 120:
  64. self.FSM.ToTransition('toLoadLevel')
  65. def Exit(self):
  66. pass
  67. #====================================
  68. class LoadLevel(State):
  69. def __init__(self,FSM):
  70. super(LoadLevel, self).__init__(FSM)
  71. def Enter(self):
  72. self.FSM.stateLife = 1
  73. super(LoadLevel, self).Enter()
  74. def Execute(self):
  75. self.FSM.stateLife += 1
  76. print('fsm loading level')
  77. Settings.loadlevel()
  78. self.FSM.ToTransition('toGameOn')
  79. def Exit(self):
  80. pass
  81. #====================================
  82. class GameOn(State):
  83. def __init__(self,FSM):
  84. super(GameOn, self).__init__(FSM)
  85. def Enter(self):
  86. self.FSM.stateLife = 1
  87. super(GameOn, self).Enter()
  88. def Execute(self):
  89. self.FSM.stateLife += 1
  90. #self.FSM.ToTransition('toLand')
  91. #print('game on')
  92. inputs.main()
  93. logo_fades.main()
  94. def Exit(self):
  95. pass
  96. #====================================