shuvit 3 years ago
parent
commit
d792878bad
3 changed files with 87 additions and 36 deletions
  1. 77
    27
      camera.py
  2. 1
    1
      controller2.py
  3. 9
    8
      walk.py

+ 77
- 27
camera.py View File

@@ -59,12 +59,12 @@ def main():
59 59
         own['last_rot_z'] = 0
60 60
         own['idlecampos_x'] = 0
61 61
         own['speed_mult'] = 1.00 
62
-        controlcube['driving'] = False     
62
+        controlcube['driving'] = False  
63
+        dict['cur_ccH_min'] = dict['cam_walk_min']
64
+        dict['cur_ccH_max'] = dict['cam_walk_max']
65
+        cam.height = dict['cam_height']
63 66
     acam = scene.active_camera
64
-    focallength = dict['focal_length']
65
-    cam1.lens = focallength
66
-    cam2.lens = focallength
67
-    cam3.lens = focallength
67
+
68 68
 
69 69
     
70 70
     #if 1 == 1:
@@ -110,8 +110,8 @@ def main():
110 110
                 pass   
111 111
         controlcube['lastCamheight'] = cam.height    
112 112
         #########
113
-        cam.min = dict['cam_min']
114
-        cam.max = dict['cam_max']
113
+        #cam.min = dict['cam_min']
114
+        #cam.max = dict['cam_max']
115 115
         cont.activate(own.actuators['Camera'])  
116 116
         ########
117 117
         
@@ -240,33 +240,26 @@ def main():
240 240
         if rot_y == 0 and own['last_rot_y'] != 0:
241 241
             rot_y = own['last_rot_y'] * damping         
242 242
                              
243
-        
244 243
         move = [move_y, 0, move_x]
245 244
         freecam.applyMovement( move, True)
246 245
         freecam.applyMovement([0, 0, move_z], False)    
247 246
         freecam.applyRotation([rot_x, 0, 0],True)
248 247
         freecam.applyRotation([0, 0, rot_y],False)
249
-
250
-#        mult = .1 #* own['speed_mult']
251
-#        if lBump == True and own['lBump'] == False:
252
-#            if own['speed_mult'] > .1:
253
-#                own['speed_mult'] = round(own['speed_mult'] - mult, 2)
254
-#        if rBump == True and own['rBump'] == False:
255
-#            if own['speed_mult'] < 5.5:
256
-#                own['speed_mult'] = round(own['speed_mult'] + mult, 2)          
257
-            
258
-            
248
+       
259 249
         
260 250
 ################    
261 251
     #print(dict['walk'], 'walk')
262 252
     multer = .02
263 253
     if dict['walk'] == 1:
264
-        if dict['cur_ccH_targetHeight'] < .8:
265
-            dist = .8 - dict['cur_ccH_targetHeight']
254
+        if dict['cur_ccH_targetHeight'] < dict['cam_walk_height']:
255
+            dist = dict['cam_walk_height'] - dict['cur_ccH_targetHeight']
266 256
             
267 257
             dict['cur_ccH_targetHeight'] = dict['cur_ccH_targetHeight'] + (dist * multer)
268
-            if dict['cur_ccH_targetHeight'] > .799:
269
-                dict['cur_ccH_targetHeight'] = .8
258
+            if dict['cur_ccH_targetHeight'] > dict['cam_walk_height']:
259
+                dict['cur_ccH_targetHeight'] = dict['cam_walk_height']
260
+                
261
+        cam.min = dict['cam_walk_min'] 
262
+        cam.max = dict['cam_walk_max']        
270 263
         #ccH_targetHeight = .9
271 264
     else:  
272 265
 
@@ -299,15 +292,72 @@ def main():
299 292
         camCube.localPosition.z += num
300 293
     #if camHeightSet not in own:
301 294
     if 1 == 1:    
302
-        #if ccheight != ccH_targetHeight:
303 295
         num = ccH_targetHeight - ccheight
304
-        #camCube.worldPosition.x = controlcube.worldPosition.x
305
-        #camCube.worldPosition.y = controlcube.worldPosition.y            
306
-        #camCube.worldPosition.z = controlcube.worldPosition.z + num
307 296
     else:
308 297
         own['camHeightSet'] = True    
309 298
            
310 299
     if dict['npause'] == False:
311 300
         cont.activate(own.actuators['Camera']) 
312
-        controlcube['camera'] = 0                
301
+        controlcube['camera'] = 0    
302
+    
303
+    cur_lens = cam1.lens
304
+    cur_min = cam.min
305
+    cur_max = cam.max
306
+    #print(cur_lens)
307
+    inc = .025
308
+    if walk == 1:
309
+        #lens
310
+        if dict['walk_focal_length'] > cur_lens:
311
+            new_lens = cur_lens + inc
312
+        else:
313
+            new_lens = cur_lens - inc
314
+        if cur_lens  > (dict['walk_focal_length'] - .1) and cur_lens  < (dict['walk_focal_length'] + .1):
315
+            new_lens = dict['walk_focal_length']  
316
+            
317
+        #distance      
318
+        inc = .025   
319
+        if cur_min > (dict['cam_walk_min'] - inc):
320
+            new_min = cur_min - inc
321
+        if cur_min < (dict['cam_walk_min'] + inc):
322
+            new_min = cur_min + inc 
323
+        if cur_max > (dict['cam_walk_max'] - inc):
324
+            new_max = cur_min - inc
325
+        if cur_max < (dict['cam_walk_max'] + inc):
326
+            new_max = cur_min + inc           
327
+    else:
328
+        #lens
329
+        if dict['focal_length'] > cur_lens:
330
+            new_lens = cur_lens + inc
331
+        else:
332
+            new_lens = cur_lens - inc 
333
+        if cur_lens  > (dict['focal_length'] - .1) and cur_lens  < (dict['focal_length'] + .1):
334
+            new_lens = dict['focal_length'] 
335
+            
336
+        #distance  
337
+        inc = .025   
338
+        if cur_min > (dict['cam_min'] - inc):
339
+            new_min = cur_min - inc
340
+        if cur_min < (dict['cam_min'] + inc):
341
+            new_min = cur_min + inc 
342
+        if cur_max > (dict['cam_max'] - inc):
343
+            new_max = cur_min - inc
344
+        if cur_max < (dict['cam_max'] + inc):
345
+            new_max = cur_min + inc        
346
+            
347
+        
348
+            
349
+                                         
350
+        
351
+    focallength = new_lens
352
+    cam1.lens = focallength
353
+    cam2.lens = focallength
354
+    cam3.lens = focallength
355
+    try:
356
+        cam.min = new_min
357
+        cam.max = new_max  
358
+        #print(new_min, new_max)     
359
+    except:
360
+        pass    
361
+    
362
+                    
313 363
 main()

+ 1
- 1
controller2.py View File

@@ -3933,7 +3933,7 @@ def main():
3933 3933
         if grindHit == False:
3934 3934
             cont.deactivate(own.actuators['grindoutRight'])
3935 3935
             cont.deactivate(own.actuators['grindoutLeft'])  
3936
-        if (grindHit == True and jumping == None and sincegrinding > 20 and ground_since > 20)or own['invert_on'] == True and own['last_grind'] == 1:
3936
+        if (LAST_GRIND == True and jumping == None and sincegrinding > 20 and ground_since > 20) or own['invert_on'] == True and LAST_GRIND == 1:
3937 3937
             outloc = 0.022
3938 3938
             bsoutloc = .07
3939 3939
             bsoutvel = .1

+ 9
- 8
walk.py View File

@@ -87,7 +87,7 @@ noidle = 0
87 87
 try:
88 88
     walk_inc = own['walk_inc'] 
89 89
 except:
90
-    own['walk_inc'] = .05
90
+    own['walk_inc'] = .01
91 91
     walk_inc = own['walk_inc']  
92 92
     own['walk_jump_timer'] = 0   
93 93
 if own['stair_counter'] != 0:
@@ -361,9 +361,9 @@ else:
361 361
     cont.deactivate(camobj.actuators['camUp'])     
362 362
                 
363 363
 #----------------
364
-camera.height = .01 #.9
365
-camera.min = 1.75
366
-camera.max = 2.25
364
+#camera.height = .01 #.9
365
+#camera.min = 1.75
366
+#camera.max = 2.25
367 367
 lasty = own['lasty']     
368 368
 
369 369
 def onboard():
@@ -531,7 +531,8 @@ def checkidle():
531 531
     if idle.positive:
532 532
         own["walk_idle_frame"] = 0
533 533
         cont.deactivate(camobj.actuators['idle_camRight'])  
534
-        camera.height = .5
534
+        #camera.height = .5
535
+        camera.height = dict['cam_idle_height']
535 536
     else: 
536 537
         if idle_frame == 0:
537 538
             own["walk_idle_frame"] = own["framenum"] 
@@ -539,9 +540,9 @@ def checkidle():
539 540
         
540 541
         if (diff > 700 and idle_frame != 0 and dropinCol.positive == False and own['walk'] != 0) or own['sit'] == 1:
541 542
             cont.activate(camobj.actuators['idle_camRight'])  
542
-            camera.height = .9   
543
-            camera.min = 2
544
-            camera.max = 2.50
543
+            #camera.height = .9   
544
+            #camera.min = 2
545
+            #camera.max = 2.50
545 546
             own['walk_idling'] = 1
546 547
         else:
547 548
             own['walk_idling'] = 0    

Loading…
Cancel
Save