Added temporary game over mechanic (just reloads the scene right now)
This commit is contained in:
parent
cf0fbfa45f
commit
fa2d82475b
3 changed files with 18 additions and 2 deletions
|
|
@ -12,6 +12,8 @@ extends Node2D
|
|||
@export var path: Path2D
|
||||
## reference to the line that draws the visual track
|
||||
@export var line: Line2D
|
||||
## reference to the player node
|
||||
@export var player: StaticBody2D
|
||||
|
||||
#variables
|
||||
var width
|
||||
|
|
@ -29,7 +31,18 @@ func _process(delta):
|
|||
if (running):
|
||||
width -= shrink_factor * delta
|
||||
update_line()
|
||||
|
||||
var p_pos = player.position
|
||||
var closest = path.curve.get_closest_point(p_pos)
|
||||
var p_dist = (p_pos - closest).length()
|
||||
print_debug(" distance from track center: ", p_dist, " current track width: ", width)
|
||||
if p_dist > width/2 - max_distance_offset:
|
||||
game_over()
|
||||
|
||||
|
||||
func update_line():
|
||||
line.set_width(width)
|
||||
|
||||
|
||||
func game_over():
|
||||
get_tree().reload_current_scene() #temp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue