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.

stance.py 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import bge
  2. from bge import logic
  3. cont = bge.logic.getCurrentController()
  4. own = cont.owner
  5. #constants
  6. STANCE_SENS = 0.05
  7. STANCE = own["stance"]
  8. jumpstance = own['jump_stance']
  9. grindpos = own['grindpos']
  10. # use game object axis
  11. local = True
  12. try:
  13. #stance detection
  14. if own['ground'] == True and (own['grindpos'] != 'reg_board' or own['grindOld'] == False) and own['invert_on'] == False:
  15. #print("detect stance")
  16. LVX = own.localLinearVelocity.x
  17. if LVX > STANCE_SENS:
  18. STANCE = 1
  19. if LVX < (-STANCE_SENS):
  20. STANCE = 0
  21. except:
  22. print("no stance")
  23. if jumpstance == 3:
  24. if own["grindOld"] == 0:
  25. own["stance"] = STANCE
  26. else:
  27. if grindpos == "reg_5050":
  28. own["stance"] = STANCE
  29. else:
  30. STANCE = jumpstance
  31. own["stance"] = STANCE
  32. dict = bge.logic.globalDict #Get the global dictionary
  33. dict['stance'] = STANCE #Store the new score
  34. #print(STANCE)
  35. #stance = dict.get('stance') #Get the current score or the number 0
  36. #print(LVX)
  37. #print(STANCE)