Skip to content

Commit

Permalink
Place tutorial portal directly in Hub.tscn (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
captaincolonelfox authored Aug 6, 2022
1 parent ec611c2 commit 840076f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
18 changes: 16 additions & 2 deletions scenes/levels/Hub.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=12 format=2]

[ext_resource path="res://scenes/levels/TileSet.tres" type="TileSet" id=1]
[ext_resource path="res://scenes/SpawnPoint.tscn" type="PackedScene" id=2]
Expand All @@ -10,6 +10,7 @@
[ext_resource path="res://scenes/ui/Themes/Default/DefaultFont.tres" type="DynamicFont" id=8]
[ext_resource path="res://scenes/friends/Blug.tscn" type="PackedScene" id=9]
[ext_resource path="res://scenes/objects/NotesNewTrigger.tscn" type="PackedScene" id=10]
[ext_resource path="res://scenes/ui/Themes/Default/default.tres" type="Theme" id=11]

[node name="Hub" type="TileMap"]
tile_set = ExtResource( 1 )
Expand Down Expand Up @@ -106,8 +107,21 @@ bbcode_text = "[right]N-Z >"
text = "N-Z >"
scroll_active = false

[node name="TutorialPortalPos" type="Position2D" parent="."]
[node name="EndPortal" parent="." instance=ExtResource( 3 )]
position = Vector2( 96, 160 )
next_level_path = "res://scenes/levels/tutorial/tutorial0.tscn"

[node name="TutorialLabel" type="Label" parent="EndPortal"]
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -48.0
margin_top = 48.0
margin_right = 48.0
margin_bottom = 64.0
theme = ExtResource( 11 )
text = "TUTORIAL"

[node name="Blug" parent="." instance=ExtResource( 9 )]
position = Vector2( -128, 192 )
Expand Down
17 changes: 3 additions & 14 deletions scripts/levels/Hub.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,11 @@ func _ready() -> void:
var label_position: Vector2 = portal_template.get_node("Label").position

var levels: Dictionary = { }
var tut_level: Dictionary = { }
for level in FileUtils.get_all_first_levels_in_dir(levels_directory):
var level_name = FileUtils.get_dir_name(level).to_upper()
if level_name != TUTORIAL_NAME:
levels[level_name] = level
else:
tut_level[TUTORIAL_NAME] = level

# Add tutorial level middle screen
if tut_level.size() > 0:
var tutorial_portal_pos : Vector2 = $TutorialPortalPos.position
create_portal(tut_level[TUTORIAL_NAME], tutorial_portal_pos)
var tutorial_label_pos : Vector2 = Vector2(
tutorial_portal_pos.x,
tutorial_portal_pos.y + portal_rect.size.y + walls_tilemap.cell_size.y / 2)
create_label(TUTORIAL_NAME, tutorial_label_pos)
if level_name == TUTORIAL_NAME:
continue
levels[level_name] = level

var n_levels: int = len(levels)
var keys: Array = levels.keys()
Expand Down

0 comments on commit 840076f

Please sign in to comment.