Skip to content

Commit

Permalink
race_manager: Implement difficulty setting
Browse files Browse the repository at this point in the history
Make use of Globals.difficulty setting to compute
checkpoints timeout value.

Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
  • Loading branch information
vknecht committed Feb 11, 2024
1 parent 6391e32 commit 4b60f45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/race_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ func add_checkpoint(path: Path3D, node : Node3D):
# Compute some basic timeout delay based on offset difference with previous CP
var timeout = 0.0
if idx > 0: # FIXME: 1st CP / startline special case...
timeout = (offset - checkpoints[idx - 1]["offset"]) / 4.0
timeout = (offset - checkpoints[idx - 1]["offset"]) / (2.0 + Globals.difficulty)
# Set 1st CP / startline timeout as if the current CP is the last one
# FIXME: don't require that 1st CP / startline has the smallest offset
checkpoints[0]["timeout"] = \
(pathLength - offset + checkpoints[0]["offset"]) / 4.0
(pathLength - offset + checkpoints[0]["offset"]) / (2.0 + Globals.difficulty)
checkpoints.push_back({ "node": node, "idx": idx, "offset": offset, "timeout": timeout })
checkpoints.sort_custom(func(a, b): return a["offset"] < b["offset"])
if idx == 0:
Expand Down

0 comments on commit 4b60f45

Please sign in to comment.