Browse Source

whisker changes

shuvit 3 years ago
parent
commit
57c390afc6
3 changed files with 84 additions and 53 deletions
  1. 1
    1
      game.blend
  2. 9
    3
      scripts/player.py
  3. 74
    49
      scripts/utils.py

+ 1
- 1
game.blend View File

@@ -1,3 +1,3 @@
1 1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:623320f4905f17477c58d6a559e9f76470a0f7dad220fd39ea196c4df59ffa90
2
+oid sha256:0daeed92152c8e05208bf67fa897d2adaa65a46f8526ec2bcce8e992c5844481
3 3
 size 1483712

+ 9
- 3
scripts/player.py View File

@@ -182,9 +182,15 @@ class hockey_player():
182 182
         self.stick = scene.addObject(to, other, 0) 
183 183
         self.puck_empty = self.cont.children['sick_puck_empty'] 
184 184
         self.puck_trigger = False
185
-        self.whisker_c_obj = self.cont.children['whisker_c'] 
186
-        self.whisker_r_obj = self.cont.children['whisker_r'] 
187
-        self.whisker_l_obj = self.cont.children['whisker_l']                 
185
+        self.whisker_objs = [self.cont.children['whisker0'], 
186
+                        self.cont.children['whisker1'], 
187
+                        self.cont.children['whisker2'], 
188
+                        self.cont.children['whisker3'], 
189
+                        self.cont.children['whisker4']]
190
+        self.whiskers = [None, None, None, None, None]                
191
+        #self.whisker_c_obj = self.cont.children['whisker0'] 
192
+        #self.whisker_r_obj = self.cont.children['whisker_r'] 
193
+        #self.whisker_l_obj = self.cont.children['whisker_l']                 
188 194
         self.whisker_c = None
189 195
         self.whisker_r = None
190 196
         self.whisker_l = None        

+ 74
- 49
scripts/utils.py View File

@@ -2,63 +2,88 @@ import bge
2 2
 
3 3
 def update_whiskers(self):
4 4
     o = self
5
-    wco = o.whisker_c_obj
6
-    wro = o.whisker_r_obj
7
-    wlo = o.whisker_l_obj
8
-    wc = o.whisker_c
9
-    wr = o.whisker_r
10
-    wl = o.whisker_l        
5
+
6
+    color = [1,1,0]
7
+    iter = 0
8
+    for w in self.whisker_objs:
9
+        rc = o.cont.rayCast(
10
+                            w.worldPosition,
11
+                            o.cont.worldPosition,
12
+                            dist = 0,
13
+                            prop = 'collision',
14
+                            face = 0,
15
+                            xray = 1,
16
+                            poly = 0,
17
+                            mask = 1)
18
+
19
+        self.whiskers[iter] = rc
20
+
21
+        iter += 1
22
+    iter = 0
23
+    for w in self.whiskers:
24
+        if w[0] is not None:
25
+            color = [1,0,0]
26
+        print(self.whiskers)
27
+        bge.render.drawLine(o.cont.worldPosition, self.whisker_objs[iter].worldPosition, color)
28
+        iter += 1
29
+
30
+    # wco = o.whisker_c_obj
31
+    # wro = o.whisker_r_obj
32
+    # wlo = o.whisker_l_obj
33
+    # wc = o.whisker_c
34
+    # wr = o.whisker_r
35
+    # wl = o.whisker_l        
11 36
     
12
-    cc = [0,0,1]
13
-    rc = [0,1,0]
14
-    lc = [0,1,0]
37
+    # cc = [0,0,1]
38
+    # rc = [0,1,0]
39
+    # lc = [0,1,0]
15 40
     
16 41
     
17
-    wc = o.cont.rayCast(wco.worldPosition, 
18
-                        o.cont.worldPosition, 
19
-                        dist = 0, 
20
-                        prop = 'collisionadf', 
21
-                        face = 0, 
22
-                        xray = 1,
23
-                        poly = 0,
24
-                        mask = 1)
42
+    # wc = o.cont.rayCast(wco.worldPosition, 
43
+    #                     o.cont.worldPosition, 
44
+    #                     dist = 0, 
45
+    #                     prop = 'collisionadf', 
46
+    #                     face = 0, 
47
+    #                     xray = 1,
48
+    #                     poly = 0,
49
+    #                     mask = 1)
25 50
                         
26 51
 
27
-    wr = o.cont.rayCast(wro.worldPosition, 
28
-                        o.cont.worldPosition, 
29
-                        dist = 0, 
30
-                        prop = 'collision', 
31
-                        face = 0, 
32
-                        xray = 1,
33
-                        poly = 0,
34
-                        mask = 1)
52
+    # wr = o.cont.rayCast(wro.worldPosition, 
53
+    #                     o.cont.worldPosition, 
54
+    #                     dist = 0, 
55
+    #                     prop = 'collision', 
56
+    #                     face = 0, 
57
+    #                     xray = 1,
58
+    #                     poly = 0,
59
+    #                     mask = 1)
35 60
                         
36 61
 
37
-    wl = o.cont.rayCast(wlo.worldPosition, 
38
-                        o.cont.worldPosition, 
39
-                        dist = 0, 
40
-                        prop = 'collision', 
41
-                        face = 0, 
42
-                        xray = 1,
43
-                        poly = 0,
44
-                        mask = 1)
62
+    # wl = o.cont.rayCast(wlo.worldPosition, 
63
+    #                     o.cont.worldPosition, 
64
+    #                     dist = 0, 
65
+    #                     prop = 'collision', 
66
+    #                     face = 0, 
67
+    #                     xray = 1,
68
+    #                     poly = 0,
69
+    #                     mask = 1)
45 70
                                                 
46 71
                                                 
47
-    if wc[0]:
48
-        cc = [1,0,0]
49
-        if 'puck' in wc[0]:
50
-            cc = [1,1,0]
51
-    if wr[0]:
52
-        rc = [1,0,0]
53
-        if 'puck' in wr[0]:
54
-            cc = [1,1,0]        
55
-    if wl[0]:
56
-        lc = [1,0,0]   
57
-        if 'puck' in wl[0]:
58
-            cc = [1,1,0]        
59
-            #print(wl[0])             
72
+    # if wc[0]:
73
+    #     cc = [1,0,0]
74
+    #     if 'puck' in wc[0]:
75
+    #         cc = [1,1,0]
76
+    # if wr[0]:
77
+    #     rc = [1,0,0]
78
+    #     if 'puck' in wr[0]:
79
+    #         cc = [1,1,0]        
80
+    # if wl[0]:
81
+    #     lc = [1,0,0]   
82
+    #     if 'puck' in wl[0]:
83
+    #         cc = [1,1,0]        
84
+    #         #print(wl[0])             
60 85
     
61
-    bge.render.drawLine(o.cont.worldPosition, wco.worldPosition, cc)
62
-    bge.render.drawLine(o.cont.worldPosition, wlo.worldPosition, lc)
63
-    bge.render.drawLine(o.cont.worldPosition, wro.worldPosition, rc)        
86
+    #bge.render.drawLine(o.cont.worldPosition, wco.worldPosition, cc)
87
+    #bge.render.drawLine(o.cont.worldPosition, wlo.worldPosition, lc)
88
+    #bge.render.drawLine(o.cont.worldPosition, wro.worldPosition, rc)        
64 89
             

Loading…
Cancel
Save