shuvit 6 years ago
parent
commit
875aacc5c2
1 changed files with 40 additions and 0 deletions
  1. 40
    0
      stance.py

+ 40
- 0
stance.py View File

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

Loading…
Cancel
Save