diff options
author | rom <romangraef@gmail.com> | 2021-04-25 16:05:09 +0200 |
---|---|---|
committer | rom <romangraef@gmail.com> | 2021-04-25 16:05:17 +0200 |
commit | 8ff102c632d39433c0a8d276e4bdacbca362dc51 (patch) | |
tree | 7f7d1f18f58af8ed5094efbc793857cc002d216c /scenes | |
parent | 2115f2305a09fce17cb2ebc74c42c2a48f4dff21 (diff) | |
download | ldjam48-8ff102c632d39433c0a8d276e4bdacbca362dc51.tar.gz ldjam48-8ff102c632d39433c0a8d276e4bdacbca362dc51.tar.bz2 ldjam48-8ff102c632d39433c0a8d276e4bdacbca362dc51.zip |
camera movement and signals
Diffstat (limited to 'scenes')
-rw-r--r-- | scenes/levels/base_level.gd | 23 | ||||
-rw-r--r-- | scenes/menu.tscn | 1 |
2 files changed, 21 insertions, 3 deletions
diff --git a/scenes/levels/base_level.gd b/scenes/levels/base_level.gd index b6f8a2e..d7dc3f7 100644 --- a/scenes/levels/base_level.gd +++ b/scenes/levels/base_level.gd @@ -13,23 +13,40 @@ const _levels = [ var _current_level = 0 var _loaded_level : Level var _track : Path2D +var _health = 10 # Called when the node enters the scene tree for the first time. func _ready(): - _health_bar.set_health(2) + _health_bar.maxhealth = 10 _load_current_level() func _get_next_level_pos() -> Vector2: - return Vector2(500, 0) + var dir = (randi() % 2) * 2 -1 + return _last_camera_location + Vector2(500, dir * (500 + randi() % 500)) func _create_path_from(from: Vector2, to: Vector2): var path = Path2D.new() var curve = Curve2D.new() + var diff = to -from curve.add_point(from) + curve.add_point(from + Vector2(diff.x, 0)) curve.add_point(to) path.curve = curve return path +func _add_hooks(): + _loaded_level.connect("level_finished", self, "_on_Level_level_finished") + _loaded_level.connect("lost_heart", self, "_on_Level_lost_heart") + +func _on_Level_level_finished(): + pass # TODO + +func _on_Level_lost_heart(): + _health -= 1 + if _health == 0: + pass # TODO: lose scenario + _health_bar.set_health(_health) + func _load_current_level(): if _loaded_level != null: push_error("Tried to load level, while another level was already loaded.") @@ -38,6 +55,7 @@ func _load_current_level(): print("Loading level at ",pos) _loaded_level = _levels[_current_level].instance() _loaded_level.position = pos + _add_hooks() _level_holder.add_child(_loaded_level) print("Level loaded") _track = _create_path_from(_last_camera_location, pos) @@ -46,7 +64,6 @@ func _load_current_level(): _path_renderer.path = _track _camera.path = _track - func _on_MenuButton_on_click(): _pause_menu.pause() diff --git a/scenes/menu.tscn b/scenes/menu.tscn index 3c1a67d..126c482 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -131,6 +131,7 @@ anims/startgame = SubResource( 2 ) [node name="Outgoing" type="AnimationPlayer" parent="."] anims/tointro = SubResource( 3 ) + [connection signal="on_click" from="Content/Exit" to="." method="_on_Exit_on_click"] [connection signal="on_click" from="Content/Strart" to="." method="_on_Strart_on_click"] [connection signal="animation_finished" from="Transitions" to="." method="_on_Transitions_animation_finished"] |