adds track parser from txt files

This commit is contained in:
2020-11-03 00:47:59 +01:00
parent d5ad9b8e1c
commit 4f2a4768c8
31 changed files with 649 additions and 103 deletions

25
Player.gd Normal file
View File

@@ -0,0 +1,25 @@
extends PathFollow2D
export (float) var speed = 0.125
var position_on_track := 0.0
var target_on_track := 0.0
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _process(delta):
# Move the player until target_on_track
if target_on_track - position_on_track > 0.01:
# Speed up car as the target_on_track goes further
var speed_mod = int(clamp((target_on_track - position_on_track) / speed, 1.0, 4.0))
position_on_track += speed * delta * speed_mod
set_unit_offset(position_on_track)
else:
position_on_track = target_on_track
func _on_RaceTrack_player_moved(track_offset):
target_on_track = track_offset