summaryrefslogtreecommitdiff
path: root/scenes/levels/base_level.gd
diff options
context:
space:
mode:
authorrom <romangraef@gmail.com>2021-04-26 20:42:25 +0200
committerrom <romangraef@gmail.com>2021-04-26 20:42:25 +0200
commit0b49ed720d9cee1cae9ce26a8685992a187078d0 (patch)
tree0833ea3187a5b38dd84658a562dc49aa64e03465 /scenes/levels/base_level.gd
parent94a5897d3361029ad4a498c1fe3f6f7216f7ce21 (diff)
downloadldjam48-0b49ed720d9cee1cae9ce26a8685992a187078d0.tar.gz
ldjam48-0b49ed720d9cee1cae9ce26a8685992a187078d0.tar.bz2
ldjam48-0b49ed720d9cee1cae9ce26a8685992a187078d0.zip
no more tracks on the first level
Diffstat (limited to 'scenes/levels/base_level.gd')
-rw-r--r--scenes/levels/base_level.gd22
1 files changed, 15 insertions, 7 deletions
diff --git a/scenes/levels/base_level.gd b/scenes/levels/base_level.gd
index 7a2c71e..68e0ccb 100644
--- a/scenes/levels/base_level.gd
+++ b/scenes/levels/base_level.gd
@@ -18,6 +18,7 @@ var _current_level = 0
var _loaded_level : Level
var _track : Path2D
var _health = 10
+var first_level = true
# Called when the node enters the scene tree for the first time.
func _ready():
@@ -65,7 +66,8 @@ func _unload_current_level():
_loaded_level = null
for c in _level_holder.get_children():
_delayed_delete(c)
- _track.queue_free()
+ if _track:
+ _track.queue_free()
yield(get_tree(), "idle_frame") # todo animation here? post mortem
func _delayed_delete(c):
@@ -82,11 +84,17 @@ func _load_current_level():
_add_hooks()
_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
+ if not first_level:
+ _track = _create_path_from(_last_camera_location, pos)
+ add_child(_track)
+ print("Tracks loaded")
+ _path_renderer.path = _track
+ _camera.path = _track
+ else:
+ first_level = false
+ _camera.path = null
+ _camera.position = pos
+ _on_Camera2D_done()
func _on_MenuButton_on_click():
_disable_input(_level_holder)
@@ -95,7 +103,7 @@ func _on_MenuButton_on_click():
func _on_Camera2D_done():
print("Camera movement done")
- _last_camera_location = $Camera2D.position
+ _last_camera_location = _camera.position
_loaded_level.start()
func _disable_input(node):