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.3KB

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