adds basic menu functionnality

This commit is contained in:
2020-11-03 23:04:17 +01:00
parent 4f2a4768c8
commit 3e10a98beb
13 changed files with 175 additions and 95 deletions

View File

@@ -1,22 +1,24 @@
extends PathFollow2D
signal lap_completed(laps)
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):
# Check if a lap was completed
if int(position_on_track) > Global.laps:
Global.laps += 1
emit_signal("lap_completed", Global.laps)
# Move the player until target_on_track
if target_on_track - position_on_track > 0.01:
elif 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)
set_unit_offset(min(position_on_track, target_on_track))
else:
position_on_track = target_on_track