summaryrefslogtreecommitdiff
path: root/scenes
diff options
context:
space:
mode:
Diffstat (limited to 'scenes')
-rw-r--r--scenes/introduction.gd4
-rw-r--r--scenes/introduction.tscn1
-rw-r--r--scenes/levels/base_level.gd53
-rw-r--r--scenes/levels/base_level.tscn34
4 files changed, 58 insertions, 34 deletions
diff --git a/scenes/introduction.gd b/scenes/introduction.gd
index ad898f2..383091b 100644
--- a/scenes/introduction.gd
+++ b/scenes/introduction.gd
@@ -1,4 +1,4 @@
-extends Node
+extends Level
# Called when the node enters the scene tree for the first time.
@@ -10,7 +10,7 @@ func _ready():
func _on_TextReveal_finished_reveal():
$Continue.visible = true
-
+ $Skip.visible = false
func _on_Button_on_click():
diff --git a/scenes/introduction.tscn b/scenes/introduction.tscn
index 2e39729..66fc128 100644
--- a/scenes/introduction.tscn
+++ b/scenes/introduction.tscn
@@ -34,6 +34,7 @@ text = "Continue"
[node name="Skip" parent="." instance=ExtResource( 3 )]
position = Vector2( 557.234, 339.165 )
text = "Skip"
+
[connection signal="finished_reveal" from="TextReveal" to="." method="_on_TextReveal_finished_reveal"]
[connection signal="on_click" from="Continue" to="." method="_on_Button_on_click"]
[connection signal="on_click" from="Skip" to="." method="_on_Skip_on_click"]
diff --git a/scenes/levels/base_level.gd b/scenes/levels/base_level.gd
index b6967c6..b6f8a2e 100644
--- a/scenes/levels/base_level.gd
+++ b/scenes/levels/base_level.gd
@@ -1,11 +1,56 @@
extends Node2D
-onready var pause_menu = $Camera2D/PauseMenu
+onready var _pause_menu = $Camera2D/PauseMenu
+onready var _level_holder = $LevelHolder
+onready var _camera : CameraTrackFollower = $Camera2D
+onready var _path_renderer : PathRenderer = $PathRenderer
+onready var _health_bar = $Camera2D/healthbar
+onready var _last_camera_location : Vector2 = $Camera2D.position
+const _levels = [
+ preload("res://scenes/introduction.tscn")
+]
+
+var _current_level = 0
+var _loaded_level : Level
+var _track : Path2D
# Called when the node enters the scene tree for the first time.
func _ready():
- $Control/TextReveal.start()
- $Camera2D/healthbar.set_health(2)
+ _health_bar.set_health(2)
+ _load_current_level()
+
+func _get_next_level_pos() -> Vector2:
+ return Vector2(500, 0)
+
+func _create_path_from(from: Vector2, to: Vector2):
+ var path = Path2D.new()
+ var curve = Curve2D.new()
+ curve.add_point(from)
+ curve.add_point(to)
+ path.curve = curve
+ return path
+
+func _load_current_level():
+ if _loaded_level != null:
+ push_error("Tried to load level, while another level was already loaded.")
+ assert(false)
+ var pos = _get_next_level_pos()
+ print("Loading level at ",pos)
+ _loaded_level = _levels[_current_level].instance()
+ _loaded_level.position = pos
+ _level_holder.add_child(_loaded_level)
+ print("Level loaded")
+ _track = _create_path_from(_last_camera_location, pos)
+ add_child(_track)
+ print("Tracks loaded")
+ _path_renderer.path = _track
+ _camera.path = _track
+
func _on_MenuButton_on_click():
- pause_menu.pause()
+ _pause_menu.pause()
+
+
+func _on_Camera2D_done():
+ print("Camera movement done")
+ _loaded_level.start()
diff --git a/scenes/levels/base_level.tscn b/scenes/levels/base_level.tscn
index ed3023a..3092a5a 100644
--- a/scenes/levels/base_level.tscn
+++ b/scenes/levels/base_level.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=9 format=2]
+[gd_scene load_steps=8 format=2]
[ext_resource path="res://textures/backgrounds/background_grey.png" type="Texture" id=1]
[ext_resource path="res://components/PathRenderer.gd" type="Script" id=2]
@@ -6,12 +6,7 @@
[ext_resource path="res://components/button.tscn" type="PackedScene" id=4]
[ext_resource path="res://scenes/pause.tscn" type="PackedScene" id=5]
[ext_resource path="res://scenes/levels/base_level.gd" type="Script" id=6]
-[ext_resource path="res://components/textreveal.gd" type="Script" id=7]
-
-[sub_resource type="Curve2D" id=1]
-_data = {
-"points": PoolVector2Array( 0, 0, 0, 0, 498.557, 573.469, 0, 0, 0, 0, 260.715, 288.06, 0, 0, 0, 0, 18.117, 259.519, 0, 0, 0, 0, -224.481, 259.519, 0, 0, 0, 0, -348.159, 264.276, 0, 0, 0, 0, -362.429, 378.439, 0, 0, 0, 0, -357.672, 559.199 )
-}
+[ext_resource path="res://components/CameraTrackFollower.gd" type="Script" id=7]
[node name="BaseLevel" type="Node2D"]
script = ExtResource( 6 )
@@ -19,6 +14,7 @@ script = ExtResource( 6 )
[node name="Camera2D" type="Camera2D" parent="."]
position = Vector2( 153.457, 427.259 )
current = true
+script = ExtResource( 7 )
[node name="healthbar" parent="Camera2D" instance=ExtResource( 3 )]
position = Vector2( -595.377, -321.363 )
@@ -35,31 +31,13 @@ texture = ExtResource( 1 )
[node name="PathRenderer" type="Node2D" parent="."]
script = ExtResource( 2 )
-
-[node name="Path2D" type="Path2D" parent="PathRenderer"]
-curve = SubResource( 1 )
+path_color = Color( 0, 0.741176, 1, 1 )
[node name="MenuButton" parent="." instance=ExtResource( 4 )]
position = Vector2( 725.099, 115.66 )
text = "Menu"
-[node name="Control" type="Control" parent="."]
-margin_left = 57.67
-margin_top = 289.516
-margin_right = 97.67
-margin_bottom = 329.516
-
-[node name="TextReveal" type="Label" parent="Control"]
-margin_right = 40.0
-margin_bottom = 14.0
-script = ExtResource( 7 )
-__meta__ = {
-"_edit_use_anchors_": false
-}
-to_render = "Im Folgenden finden Sie Neuerungen/Änderungen zu den nationalen und internationalen Beförderungsbedingungen der DB Fernverkehr AG und der DB Regio AG gemäß Paragraph 12 Absatz 6 Allgemeines Eisenbahngesetz (AEG).
-Tarifbekanntmachung national DB Fernverkehr AG und DB Regio AG, Stand 16.04.2021 (PDF, 261KB)
-Tarifbekanntmachungen international DB Fernverkehr AG, Stand 24.04.2021 (PDF, 128KB)"
-speed = 10.0
-
[node name="LevelHolder" type="Node2D" parent="."]
+
+[connection signal="done" from="Camera2D" to="." method="_on_Camera2D_done"]
[connection signal="on_click" from="MenuButton" to="." method="_on_MenuButton_on_click"]