From a6cf1d882adec3c34b809c832615fefab924e870 Mon Sep 17 00:00:00 2001 From: IcECreAm777 Date: Sun, 9 Jul 2023 13:59:48 +0200 Subject: template level & setting offset to the start button so the car is in the middle --- Levels/LevelTemplate.tscn | 66 ++++++++++++++++++++++++++++++++++++++++++ Nodes/Level_test.tscn | 73 ----------------------------------------------- Scripts/scene_control.gd | 6 ++-- 3 files changed, 69 insertions(+), 76 deletions(-) create mode 100644 Levels/LevelTemplate.tscn delete mode 100644 Nodes/Level_test.tscn diff --git a/Levels/LevelTemplate.tscn b/Levels/LevelTemplate.tscn new file mode 100644 index 0000000..86ea221 --- /dev/null +++ b/Levels/LevelTemplate.tscn @@ -0,0 +1,66 @@ +[gd_scene load_steps=10 format=3 uid="uid://dliou1u4o6bib"] + +[ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_2b4bf"] +[ext_resource type="PackedScene" uid="uid://c8r6i3bu37ogu" path="res://Nodes/ui.tscn" id="2_2w0c4"] +[ext_resource type="Texture2D" uid="uid://5xqahgawme4m" path="res://Assets/start.png" id="3_ckyv7"] +[ext_resource type="Texture2D" uid="uid://b8vhe5kt6037n" path="res://Assets/end.png" id="4_2vjhv"] +[ext_resource type="PackedScene" uid="uid://c1mvbh2fwqtkb" path="res://Nodes/car.tscn" id="5_v816p"] +[ext_resource type="Script" path="res://Scripts/drawing.gd" id="6_ihf71"] +[ext_resource type="Texture2D" uid="uid://dg3v488vx0oj6" path="res://Assets/checkpoint.png" id="7_bofa3"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_6g88q"] +radius = 18.0278 + +[sub_resource type="Curve2D" id="Curve2D_0exre"] + +[node name="Level_test" type="Node2D"] +script = ExtResource("1_2b4bf") + +[node name="UI" parent="." instance=ExtResource("2_2w0c4")] + +[node name="Start" type="Node2D" parent="."] +position = Vector2(256, 422) + +[node name="Start" type="TextureButton" parent="Start"] +offset_left = -16.0 +offset_top = -16.0 +offset_right = 16.0 +offset_bottom = 16.0 +texture_normal = ExtResource("3_ckyv7") + +[node name="FinishLine" type="Sprite2D" parent="."] +position = Vector2(793, 96) +texture = ExtResource("4_2vjhv") + +[node name="Area2D" type="Area2D" parent="FinishLine"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="FinishLine/Area2D"] +shape = SubResource("CircleShape2D_6g88q") + +[node name="Car" parent="." instance=ExtResource("5_v816p")] +max_speed = 500 +acceleration = 0.05 + +[node name="DrawNode" type="Node2D" parent="."] +script = ExtResource("6_ihf71") + +[node name="TrackLine" type="Line2D" parent="DrawNode"] + +[node name="TrackPath" type="Path2D" parent="DrawNode"] +curve = SubResource("Curve2D_0exre") + +[node name="TrackFollower" type="PathFollow2D" parent="DrawNode/TrackPath"] +loop = false + +[node name="Sprite2D" type="Sprite2D" parent="DrawNode/TrackPath/TrackFollower"] +visible = false +scale = Vector2(0.604, 0.604) +texture = ExtResource("7_bofa3") + +[node name="31005" type="Timer" parent="DrawNode/TrackPath/TrackFollower"] +wait_time = 0.2 +one_shot = true + +[node name="Checkpoints" type="Node" parent="."] + +[connection signal="mouse_entered" from="FinishLine/Area2D" to="DrawNode" method="_end_drawing"] diff --git a/Nodes/Level_test.tscn b/Nodes/Level_test.tscn deleted file mode 100644 index f082198..0000000 --- a/Nodes/Level_test.tscn +++ /dev/null @@ -1,73 +0,0 @@ -[gd_scene load_steps=11 format=3 uid="uid://dliou1u4o6bib"] - -[ext_resource type="Script" path="res://Scripts/scene_control.gd" id="1_0esj3"] -[ext_resource type="Texture2D" uid="uid://5xqahgawme4m" path="res://Assets/start.png" id="1_wenkl"] -[ext_resource type="Texture2D" uid="uid://b8vhe5kt6037n" path="res://Assets/end.png" id="2_gp6ng"] -[ext_resource type="Texture2D" uid="uid://dg3v488vx0oj6" path="res://Assets/checkpoint.png" id="3_cgigr"] -[ext_resource type="PackedScene" uid="uid://c1mvbh2fwqtkb" path="res://Nodes/car.tscn" id="4_xvobs"] -[ext_resource type="Script" path="res://Scripts/drawing.gd" id="5_x7h3g"] -[ext_resource type="PackedScene" uid="uid://wkfai2lvnp7n" path="res://Nodes/checkpoint.tscn" id="7_52mhf"] -[ext_resource type="PackedScene" uid="uid://c8r6i3bu37ogu" path="res://Nodes/ui.tscn" id="8_8u1ba"] - -[sub_resource type="CircleShape2D" id="CircleShape2D_6g88q"] -radius = 18.0278 - -[sub_resource type="Curve2D" id="Curve2D_0exre"] - -[node name="Level_test" type="Node2D"] -script = ExtResource("1_0esj3") - -[node name="UI" parent="." instance=ExtResource("8_8u1ba")] - -[node name="Start" type="TextureButton" parent="."] -offset_left = 787.0 -offset_top = 514.0 -offset_right = 819.0 -offset_bottom = 546.0 -texture_normal = ExtResource("1_wenkl") - -[node name="FinishLine" type="Sprite2D" parent="."] -position = Vector2(793, 96) -texture = ExtResource("2_gp6ng") - -[node name="Area2D" type="Area2D" parent="FinishLine"] - -[node name="CollisionShape2D" type="CollisionShape2D" parent="FinishLine/Area2D"] -shape = SubResource("CircleShape2D_6g88q") - -[node name="Car" parent="." instance=ExtResource("4_xvobs")] -max_speed = 500 -acceleration = 0.05 - -[node name="DrawNode" type="Node2D" parent="."] -script = ExtResource("5_x7h3g") - -[node name="TrackLine" type="Line2D" parent="DrawNode"] - -[node name="TrackPath" type="Path2D" parent="DrawNode"] -curve = SubResource("Curve2D_0exre") - -[node name="TrackFollower" type="PathFollow2D" parent="DrawNode/TrackPath"] -loop = false - -[node name="Sprite2D" type="Sprite2D" parent="DrawNode/TrackPath/TrackFollower"] -visible = false -scale = Vector2(0.604, 0.604) -texture = ExtResource("3_cgigr") - -[node name="31005" type="Timer" parent="DrawNode/TrackPath/TrackFollower"] -wait_time = 0.2 -one_shot = true - -[node name="Checkpoints" type="Node" parent="."] - -[node name="Checkpoint" parent="Checkpoints" instance=ExtResource("7_52mhf")] -position = Vector2(619, 355) - -[node name="Checkpoint2" parent="Checkpoints" instance=ExtResource("7_52mhf")] -position = Vector2(285, 479) - -[node name="Checkpoint3" parent="Checkpoints" instance=ExtResource("7_52mhf")] -position = Vector2(517, 172) - -[connection signal="mouse_entered" from="FinishLine/Area2D" to="DrawNode" method="_end_drawing"] diff --git a/Scripts/scene_control.gd b/Scripts/scene_control.gd index ce3332f..73d9273 100644 --- a/Scripts/scene_control.gd +++ b/Scripts/scene_control.gd @@ -8,12 +8,12 @@ class_name SceneControl @onready var checkpoints = $Checkpoints.get_children() @onready var ui = $UI/Control @onready var drawing = $DrawNode +@onready var start = $Start var is_driving = false var current_time = 0.0 var game_control -var start func _ready(): @@ -23,8 +23,8 @@ func _ready(): $UI/Control/PostGameUI/RestartButton.pressed.connect(reset_level) $UI/Control/PostGameUI/NextLevelButton.pressed.connect(next_level) - start = $Start as TextureButton - start.pressed.connect(start_drawing) + var start_button = $Start/Start as TextureButton + start_button.pressed.connect(start_drawing) reset_level() -- cgit