diff --git a/scripts/game.gd b/scripts/game.gd index 1f7054c..ec584ee 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -18,17 +18,19 @@ const caroffset= 32+4 #space cars on start line const caroffset_side= 16 const caroffset_rear= 32+16 -var viewCarMargin=Vector2(0.7,0.7) #1=zoom out full speed when car is at border. 0.9 zoom out full speed when car is 10% away from border -var viewCarMargin_zoomstart=viewCarMargin-Vector2(0.2,0.2) #start zooming -var viewCarMargin_zoombackup=viewCarMargin_zoomstart-Vector2(0.1,0.1) #start zooming back in -var zoomspeed=0.5 +var viewCarMargin=Vector2(0.9,0.9) #1=zoom out full speed when car is at border. 0.9 zoom out full speed when car is 10% away from border +var viewCarMargin_zoomstart=viewCarMargin-Vector2(0.3,0.3) #start zooming out +var viewCarMargin_zoombackup=viewCarMargin_zoomstart-Vector2(0.1,0.1) #fullspeed zooming back in +var zoomspeed=1.0 var zoomspeed_backup=0.1 #relative to screen size + var zoom_normal=1.5 -const CAMERA_POSITION_SPEED=0.02 #0.0 - 1.0, higher=faster -var camera_zoom_out_lookahead_time=1 #predicted position of car in t seconds for camera coverage. greater value=earlier zoom out and movement of camera +const CAMERA_POSITION_SPEED=0.025 #0.0 - 1.0, higher=faster +var camera_zoom_out_lookahead_time=1.5 #predicted position of car in t seconds for camera coverage. greater value=earlier zoom out and movement of camera var running=false + var highscorecheckpointtimes=null var time_close_keypressed=1 #seconds to wait after key pressed at endscreen @@ -185,21 +187,28 @@ func updateCameraMovement(delta: float): var carSpread=Vector2(maxPos.x-minPos.x,maxPos.y-minPos.y) var calculatedViewCarMargin=carSpread*camera.zoom #when cars are screen width apart this number matches viewsize=camera.get_viewport_rect().size - + #calculatedViewCarMargin darf nicht > viewsize werden #print("viewsize="+str(viewsize)+" carSpread="+str(carSpread)+" calculatedViewCarMargin="+str(calculatedViewCarMargin)+" zoom="+str(camera.zoom)) - var viewCarMargin_zoomstart_pixels=viewCarMargin_zoomstart*viewsize/camera.zoom - var viewCarMargin_pixels=viewCarMargin*viewsize/camera.zoom - var viewCarMargin_zoombackup_pixels=viewCarMargin_zoombackup*viewsize/camera.zoom + #var viewCarMargin_zoomstart_pixels=viewCarMargin_zoomstart*viewsize/camera.zoom + var viewCarMargin_zoomstart_pixels=viewCarMargin_zoomstart*viewsize + #var viewCarMargin_pixels=viewCarMargin*viewsize/camera.zoom + var viewCarMargin_pixels=viewCarMargin*viewsize + #var viewCarMargin_zoombackup_pixels=viewCarMargin_zoombackup*viewsize/camera.zoom + var viewCarMargin_zoombackup_pixels=viewCarMargin_zoombackup*viewsize + - var mapped_zoomspeed_x=constrain(remap(calculatedViewCarMargin.x , viewCarMargin_zoomstart_pixels.x,viewCarMargin_pixels.x,0,zoomspeed),0,zoomspeed) - var mapped_zoomspeed_y=constrain(remap(calculatedViewCarMargin.y , viewCarMargin_zoomstart_pixels.y,viewCarMargin_pixels.y,0,zoomspeed),0,zoomspeed) - var mapped_zoomspeed=max(mapped_zoomspeed_x,mapped_zoomspeed_y) if calculatedViewCarMargin.x>viewCarMargin_zoomstart_pixels.x or calculatedViewCarMargin.y>viewCarMargin_zoomstart_pixels.y: #cars not in view + var mapped_zoomspeed_x=constrain(remap(calculatedViewCarMargin.x , viewCarMargin_zoomstart_pixels.x,viewCarMargin_pixels.x,0,zoomspeed),0,zoomspeed) + var mapped_zoomspeed_y=constrain(remap(calculatedViewCarMargin.y , viewCarMargin_zoomstart_pixels.y,viewCarMargin_pixels.y,0,zoomspeed),0,zoomspeed) + var mapped_zoomspeed=max(mapped_zoomspeed_x,mapped_zoomspeed_y) + mapped_zoomspeed=pow(mapped_zoomspeed/zoomspeed,2)*zoomspeed #apply exponent curve (slow when less zoom speed, faster when faster zoom) camera.zoom-=Vector2(mapped_zoomspeed*delta,mapped_zoomspeed*delta) - elif calculatedViewCarMargin.x