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
|
@export var path: Path2D
|
||||||
## reference to the line that draws the visual track
|
## reference to the line that draws the visual track
|
||||||
@export var line: Line2D
|
@export var line: Line2D
|
||||||
|
## reference to the player node
|
||||||
|
@export var player: StaticBody2D
|
||||||
|
|
||||||
#variables
|
#variables
|
||||||
var width
|
var width
|
||||||
|
@ -29,7 +31,18 @@ func _process(delta):
|
||||||
if (running):
|
if (running):
|
||||||
width -= shrink_factor * delta
|
width -= shrink_factor * delta
|
||||||
update_line()
|
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():
|
func update_line():
|
||||||
line.set_width(width)
|
line.set_width(width)
|
||||||
|
|
||||||
|
|
||||||
|
func game_over():
|
||||||
|
get_tree().reload_current_scene() #temp
|
||||||
|
|
|
@ -10,12 +10,13 @@ _data = {
|
||||||
}
|
}
|
||||||
point_count = 7
|
point_count = 7
|
||||||
|
|
||||||
[node name="level1" type="Node2D" node_paths=PackedStringArray("path", "line")]
|
[node name="level1" type="Node2D" node_paths=PackedStringArray("path", "line", "player")]
|
||||||
script = ExtResource("1_hv75i")
|
script = ExtResource("1_hv75i")
|
||||||
starting_width = 400.0
|
starting_width = 400.0
|
||||||
shrink_factor = 0.5
|
shrink_factor = 5.0
|
||||||
path = NodePath("TrackPath")
|
path = NodePath("TrackPath")
|
||||||
line = NodePath("TrackLine")
|
line = NodePath("TrackLine")
|
||||||
|
player = NodePath("player")
|
||||||
|
|
||||||
[node name="TrackPath" type="Path2D" parent="."]
|
[node name="TrackPath" type="Path2D" parent="."]
|
||||||
curve = SubResource("Curve2D_ll8bj")
|
curve = SubResource("Curve2D_ll8bj")
|
||||||
|
@ -27,3 +28,4 @@ texture_mode = 2
|
||||||
|
|
||||||
[node name="player" parent="." instance=ExtResource("2_5nf51")]
|
[node name="player" parent="." instance=ExtResource("2_5nf51")]
|
||||||
position = Vector2(42.7545, -14.9219)
|
position = Vector2(42.7545, -14.9219)
|
||||||
|
brake_strength = 800.0
|
||||||
|
|
|
@ -11,6 +11,7 @@ script = ExtResource("1_g4ij8")
|
||||||
turn_speed = 0.8
|
turn_speed = 0.8
|
||||||
brake_strength = 600.0
|
brake_strength = 600.0
|
||||||
drift_factor = 1.2
|
drift_factor = 1.2
|
||||||
|
camera_offset = 200.0
|
||||||
camera = NodePath("Camera2D")
|
camera = NodePath("Camera2D")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
|
Loading…
Reference in a new issue