diff --git a/Scenes/DungeonScene/dungeon_scene.tscn b/Scenes/DungeonScene/dungeon_scene.tscn index 4b2195b..338bf21 100644 --- a/Scenes/DungeonScene/dungeon_scene.tscn +++ b/Scenes/DungeonScene/dungeon_scene.tscn @@ -2,6 +2,17 @@ [ext_resource type="PackedScene" uid="uid://5viursrnvdyf" path="res://Scenes/Player/player.tscn" id="1_okyhq"] [ext_resource type="PackedScene" uid="uid://dhvuy8co661xo" path="res://Scenes/SceneEntrance/scene_entrance.tscn" id="1_xuufh"] +[ext_resource type="Texture2D" uid="uid://c3l7w3n700qx3" path="res://Ninja Adventure - Asset Pack/Backgrounds/Tilesets/TilesetReliefDetail.png" id="3_sx8ki"] + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_6f4q3"] +texture = ExtResource("3_sx8ki") +0:7/size_in_atlas = Vector2i(3, 3) +0:7/0 = 0 +3:7/size_in_atlas = Vector2i(3, 3) +3:7/0 = 0 + +[sub_resource type="TileSet" id="TileSet_bqpwv"] +sources/0 = SubResource("TileSetAtlasSource_6f4q3") [node name="DungeonScene" type="Node2D" unique_id=1981353208] @@ -11,5 +22,10 @@ zoom = Vector2(5, 5) [node name="SceneEntrance" parent="." unique_id=1734357035 instance=ExtResource("1_xuufh")] -position = Vector2(0, 30) +position = Vector2(42, 1) next_scene = "res://Scenes/GameScene/game_scene.tscn" +player_spawn_pos = Vector2(137, -91) + +[node name="ObstacleLayer" type="TileMapLayer" parent="." unique_id=1536979901] +tile_map_data = PackedByteArray(0, 0, 2, 0, 255, 255, 0, 0, 3, 0, 7, 0, 0, 0) +tile_set = SubResource("TileSet_bqpwv") diff --git a/Scenes/Player/player.gd b/Scenes/Player/player.gd index 279f317..811de91 100644 --- a/Scenes/Player/player.gd +++ b/Scenes/Player/player.gd @@ -7,7 +7,7 @@ class_name Player # Called when the node enters the scene tree for the first time. func _ready() -> void: var damage: float = 2 - print(damage) + position = SceneManager.player_next_scene_spawn_pos # Called every frame. 'delta' is the elapsed time since the previous frame. diff --git a/Scenes/SceneEntrance/scene_entrance.gd b/Scenes/SceneEntrance/scene_entrance.gd index 20a21a7..768ddab 100644 --- a/Scenes/SceneEntrance/scene_entrance.gd +++ b/Scenes/SceneEntrance/scene_entrance.gd @@ -1,5 +1,6 @@ extends Area2D @export var next_scene: String +@export var player_spawn_pos: Vector2 # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -13,6 +14,7 @@ func _process(delta: float) -> void: func _on_body_entered(body: Player) -> void: print("body entered!") + $"/root/SceneManager".player_next_scene_spawn_pos = player_spawn_pos get_tree().change_scene_to_file.call_deferred(next_scene) pass # Replace with function body. diff --git a/Scenes/SceneManager/scene_manager.gd b/Scenes/SceneManager/scene_manager.gd new file mode 100644 index 0000000..bfb4973 --- /dev/null +++ b/Scenes/SceneManager/scene_manager.gd @@ -0,0 +1,12 @@ +extends Node2D + +var player_next_scene_spawn_pos: Vector2 + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/Scenes/SceneManager/scene_manager.gd.uid b/Scenes/SceneManager/scene_manager.gd.uid new file mode 100644 index 0000000..ab5cb1d --- /dev/null +++ b/Scenes/SceneManager/scene_manager.gd.uid @@ -0,0 +1 @@ +uid://bghfl5hagv6q1 diff --git a/Scenes/SceneManager/scene_manager.tscn b/Scenes/SceneManager/scene_manager.tscn new file mode 100644 index 0000000..fb3da02 --- /dev/null +++ b/Scenes/SceneManager/scene_manager.tscn @@ -0,0 +1,6 @@ +[gd_scene format=3 uid="uid://6txu74mchftj"] + +[ext_resource type="Script" uid="uid://bghfl5hagv6q1" path="res://Scenes/SceneManager/scene_manager.gd" id="1_car14"] + +[node name="SceneManager" type="Node2D" unique_id=402183888] +script = ExtResource("1_car14") diff --git a/project.godot b/project.godot index 23866c9..bb35204 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,10 @@ run/main_scene="uid://bhjxpugl4fg33" config/features=PackedStringArray("4.7", "Forward Plus") config/icon="res://icon.svg" +[autoload] + +SceneManager="*uid://6txu74mchftj" + [display] window/stretch/mode="canvas_items"