Added a score submitting menu; added level nr variable in levels
This commit is contained in:
parent
fd1164b2f6
commit
7790c3cc07
6 changed files with 117 additions and 8 deletions
|
@ -11,6 +11,8 @@ extends Node2D
|
|||
## margin for error when checking for laps being driven
|
||||
@export var lap_count_margin := 50
|
||||
|
||||
@export var level_nr := 1
|
||||
|
||||
#references
|
||||
## reference to the path describing the track
|
||||
@export var path: Path2D
|
||||
|
@ -116,7 +118,11 @@ func game_over():
|
|||
running = false
|
||||
player.dead = true
|
||||
$player/death_sound.play()
|
||||
print_debug("final score: ", get_total_distance())
|
||||
# print_debug("final score: ", get_total_distance())
|
||||
await get_tree().create_timer(3).timeout
|
||||
|
||||
get_tree().reload_current_scene() #temp
|
||||
var submit = load("res://src/gui/menu/score_submit.tscn").instantiate()
|
||||
submit.highscore = get_total_distance()
|
||||
submit.level_nr = level_nr
|
||||
menu.add_child(submit)
|
||||
menu.show()
|
||||
# get_tree().reload_current_scene() #temp
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://ds0un04pocx6i" path="res://assets/track_90_bk.png" id="3_en5wc"]
|
||||
[ext_resource type="Texture2D" uid="uid://dmcrms0qu0mtt" path="res://assets/finish2.png" id="4_qeube"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckau5s2tsb3oc" path="res://src/game/player.tscn" id="5_2n8nj"]
|
||||
[ext_resource type="PackedScene" uid="uid://dyo5dblkfivwn" path="res://src/gui/menu/level.tscn" id="6_hs25h"]
|
||||
[ext_resource type="PackedScene" uid="uid://c0sexrwxdge73" path="res://src/gui/menu/level.tscn" id="6_hs25h"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdlbh3smpgg42" path="res://src/gui/hud/hud.tscn" id="6_r1i0q"]
|
||||
[ext_resource type="Texture2D" uid="uid://bq151lkkfdlf4" path="res://assets/sign.png" id="7_xmahe"]
|
||||
[ext_resource type="PackedScene" uid="uid://ya1ctigi23wa" path="res://assets/sign.tscn" id="8_i27bq"]
|
||||
|
@ -42,7 +42,6 @@ texture = ExtResource("2_4qg8j")
|
|||
stretch_mode = 1
|
||||
|
||||
[node name="Background" type="TextureRect" parent="."]
|
||||
visible = false
|
||||
self_modulate = Color(0.827451, 0.521569, 0.313726, 1)
|
||||
offset_left = -6505.0
|
||||
offset_top = -3355.0
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://dmcrms0qu0mtt" path="res://assets/finish2.png" id="4_1w2e5"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckau5s2tsb3oc" path="res://src/game/player.tscn" id="5_4d0xw"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdlbh3smpgg42" path="res://src/gui/hud/hud.tscn" id="6_tmqkf"]
|
||||
[ext_resource type="PackedScene" uid="uid://dyo5dblkfivwn" path="res://src/gui/menu/level.tscn" id="7_bv3bp"]
|
||||
[ext_resource type="PackedScene" uid="uid://c0sexrwxdge73" path="res://src/gui/menu/level.tscn" id="7_bv3bp"]
|
||||
[ext_resource type="AudioStream" uid="uid://dh5jxxwim7ra8" path="res://assets/sounds/music/death_by_waveshaper.wav" id="9_vi54e"]
|
||||
[ext_resource type="PackedScene" uid="uid://da1mcxm6jcpbo" path="res://assets/arrow_light_2.tscn" id="10_k8jma"]
|
||||
[ext_resource type="PackedScene" uid="uid://ebmku7hq0mxi" path="res://assets/arrow_light_1.tscn" id="10_pjhii"]
|
||||
|
@ -24,6 +24,7 @@ point_count = 10
|
|||
script = ExtResource("1_ijrq0")
|
||||
starting_width = 400.0
|
||||
shrink_factor = 5.0
|
||||
level_nr = 2
|
||||
path = NodePath("TrackPath")
|
||||
line = NodePath("TrackLine")
|
||||
player = NodePath("player")
|
||||
|
@ -41,7 +42,6 @@ texture = ExtResource("2_ugncc")
|
|||
stretch_mode = 1
|
||||
|
||||
[node name="Background" type="TextureRect" parent="."]
|
||||
visible = false
|
||||
self_modulate = Color(0.0313726, 0.737255, 0, 1)
|
||||
offset_left = -10462.0
|
||||
offset_top = -14103.0
|
||||
|
|
|
@ -153,7 +153,7 @@ grow_vertical = 0
|
|||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
focus_neighbor_bottom = NodePath("../StartButton")
|
||||
text = "Back"
|
||||
text = "BACK"
|
||||
|
||||
[connection signal="value_changed" from="Background/VBoxContainer/Brightness" to="Background/VBoxContainer/Brightness" method="_on_value_changed"]
|
||||
[connection signal="pressed" from="Background/BackButton" to="." method="_on_back_button_pressed"]
|
||||
|
|
14
src/gui/menu/score_submit.gd
Normal file
14
src/gui/menu/score_submit.gd
Normal file
|
@ -0,0 +1,14 @@
|
|||
extends Control
|
||||
|
||||
@export var score_label: Label
|
||||
@export var name_field: LineEdit
|
||||
|
||||
var highscore
|
||||
var level_nr
|
||||
|
||||
func _ready():
|
||||
score_label.set_text("%.f" % highscore)
|
||||
|
||||
func _on_sumbit_button_pressed():
|
||||
pass #insert score sumbitting function here
|
||||
#then proceed to highscore screen
|
90
src/gui/menu/score_submit.tscn
Normal file
90
src/gui/menu/score_submit.tscn
Normal file
|
@ -0,0 +1,90 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dn7406kgso117"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://dpktnl3r5wul1" path="res://src/gui/menu_theme.tres" id="1_d82sr"]
|
||||
[ext_resource type="Script" path="res://src/gui/menu/score_submit.gd" id="2_ejneg"]
|
||||
|
||||
[node name="score_submit" type="Control" node_paths=PackedStringArray("score_label", "name_field")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_d82sr")
|
||||
script = ExtResource("2_ejneg")
|
||||
score_label = NodePath("Panel/VBoxContainer/ScoreLabel")
|
||||
name_field = NodePath("Panel/VBoxContainer/NameField")
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -131.0
|
||||
offset_top = -231.0
|
||||
offset_right = 132.0
|
||||
offset_bottom = 169.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -52.0
|
||||
offset_top = 24.0
|
||||
offset_right = 52.0
|
||||
offset_bottom = 50.0
|
||||
grow_horizontal = 2
|
||||
text = "GAME OVER"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -49.5
|
||||
offset_top = -81.0
|
||||
offset_right = 49.5
|
||||
offset_bottom = 7.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "SCORE"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ScoreLabel" type="Label" parent="Panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="NameField" type="LineEdit" parent="Panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
placeholder_text = "enter name"
|
||||
expand_to_text_length = true
|
||||
|
||||
[node name="SubmitButton" type="Button" parent="Panel"]
|
||||
custom_minimum_size = Vector2(120, 40)
|
||||
layout_mode = 1
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -60.0
|
||||
offset_top = -109.0
|
||||
offset_right = 60.0
|
||||
offset_bottom = -69.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 8
|
||||
focus_neighbor_bottom = NodePath("../StartButton")
|
||||
text = "SUBMIT"
|
Loading…
Reference in a new issue