From 57303f8d57e42590bcfe24b43399ca6ab9d1a65a Mon Sep 17 00:00:00 2001 From: Fisch Date: Mon, 11 Nov 2024 19:09:24 +0100 Subject: [PATCH] improve tiretrails --- scripts/car.gd | 5 +++++ scripts/car_node.gd | 1 + scripts/tiretrails.gd | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/car.gd b/scripts/car.gd index 0bbf2f7..be81119 100644 --- a/scripts/car.gd +++ b/scripts/car.gd @@ -82,6 +82,7 @@ var burnout:float=0 #at 0 is off @onready var sfx: Node = $SFX + var playerid=0 var finalTime=-1 @@ -113,11 +114,15 @@ func _physics_process(delta: float) -> void: var collision = get_slide_collision(i) if $".".name==collision.get_collider().name: #collided with another car sfx.crashCarToCar(velocity.length()) + #collision.get_collider_velocity().length() # velocity-=COLLISION_SLOWDOWN_CAR if ROAD_R_NAME==collision.get_collider().name or ROAD_L_NAME==collision.get_collider().name: #collided with road if (velocity.length()>MIN_CRASH_VELOCITY): velocity/=COLLISION_SLOWDOWN_WALL + #sfx.crashBarrier(velocity.length()) sfx.crashBarrier(velocity.length()) + + #if get_slide_collision_count()>0: # velocity/=2 diff --git a/scripts/car_node.gd b/scripts/car_node.gd index c402756..c63722b 100644 --- a/scripts/car_node.gd +++ b/scripts/car_node.gd @@ -20,6 +20,7 @@ func setPlayerinformation(playerid, playercolor): cbcar.playerid=playerid carbody.modulate = playercolor + func setCheckpoints(cps,rounds): cbcar.checkpoints=cps cbcar.checkpointtimes.resize(cps.size()*rounds) diff --git a/scripts/tiretrails.gd b/scripts/tiretrails.gd index 5dd28fb..19cd61b 100644 --- a/scripts/tiretrails.gd +++ b/scripts/tiretrails.gd @@ -6,7 +6,7 @@ var isSliding=false var currentTrail:Line2D -const STARTALPHA=0.8 +const STARTALPHA=0.5 const MAXIMUM_POINTS=100 #maximum points per trail const FADETIME=120 #in seconds. how long a trail should last (if alpha would start at 1.0) @@ -26,7 +26,7 @@ func _physics_process(delta: float) -> void: c.queue_free() func setSliding(psliding:bool): - if not isSliding and psliding: #just started sliding + if not isSliding and psliding: #just started sliding #Create new Line currentTrail=Line2D.new() add_child(currentTrail) @@ -37,7 +37,7 @@ func setSliding(psliding:bool): curve.add_point(Vector2(0.5,1),0,0,Curve.TANGENT_FREE,Curve.TANGENT_FREE) curve.add_point(Vector2(1,0),-5,0,Curve.TANGENT_FREE,Curve.TANGENT_FREE) currentTrail.width_curve=curve - currentTrail.set_as_top_level(true) + currentTrail.set_as_top_level(true) #position is global position currentTrail.z_index=8 #above road, behind car isSliding=psliding