Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene switch fixed #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions UI/main_menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ blend_mode = 3
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_aucoj"]
blend_mode = 1

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_r1ihh"]
bg_color = Color(0.6, 0.6, 0.6, 0)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_t6cof"]
bg_color = Color(0.6, 0.6, 0.6, 0)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_r114s"]
bg_color = Color(0.6, 0.6, 0.6, 0)
border_color = Color(0.8, 0.8, 0.8, 0)
Expand All @@ -27,12 +33,6 @@ shadow_color = Color(0, 0, 0, 0)
shadow_size = 5
shadow_offset = Vector2(2, 2)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_t6cof"]
bg_color = Color(0.6, 0.6, 0.6, 0)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_r1ihh"]
bg_color = Color(0.6, 0.6, 0.6, 0)

[node name="main_menu" type="Control"]
layout_mode = 3
anchors_preset = 15
Expand Down Expand Up @@ -115,42 +115,42 @@ layout_mode = 2
[node name="PlayButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer"]
custom_minimum_size = Vector2(160, 64)
layout_mode = 2
theme_override_colors/font_color = Color(0.960784, 0.196078, 0, 1)
theme_override_colors/font_hover_color = Color(0.796078, 0.505882, 0, 1)
theme_override_colors/font_focus_color = Color(0.533333, 0, 0, 1)
theme_override_colors/font_color = Color(0.960784, 0.196078, 0, 1)
theme_override_fonts/font = ExtResource("5_dhigr")
theme_override_font_sizes/font_size = 50
theme_override_styles/normal = SubResource("StyleBoxFlat_r114s")
theme_override_styles/hover = SubResource("StyleBoxFlat_t6cof")
theme_override_styles/focus = SubResource("StyleBoxFlat_r1ihh")
theme_override_styles/hover = SubResource("StyleBoxFlat_t6cof")
theme_override_styles/normal = SubResource("StyleBoxFlat_r114s")
text = "Start the Loop
"

[node name="OptionButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer"]
custom_minimum_size = Vector2(160, 64)
layout_mode = 2
theme_override_colors/font_color = Color(0.960784, 0.196078, 0, 1)
theme_override_colors/font_hover_color = Color(0.796078, 0.505882, 0, 1)
theme_override_colors/font_focus_color = Color(0.533333, 0, 0, 1)
theme_override_colors/font_color = Color(0.960784, 0.196078, 0, 1)
theme_override_fonts/font = ExtResource("5_dhigr")
theme_override_font_sizes/font_size = 50
theme_override_styles/normal = SubResource("StyleBoxFlat_r114s")
theme_override_styles/hover = SubResource("StyleBoxFlat_t6cof")
theme_override_styles/focus = SubResource("StyleBoxFlat_r1ihh")
theme_override_styles/hover = SubResource("StyleBoxFlat_t6cof")
theme_override_styles/normal = SubResource("StyleBoxFlat_r114s")
text = "Change the Loop
"

[node name="ExitButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer"]
custom_minimum_size = Vector2(160, 64)
layout_mode = 2
theme_override_colors/font_color = Color(0.960784, 0.196078, 0, 1)
theme_override_colors/font_hover_color = Color(0.796078, 0.505882, 0, 1)
theme_override_colors/font_focus_color = Color(0.533333, 0, 0, 1)
theme_override_colors/font_color = Color(0.960784, 0.196078, 0, 1)
theme_override_fonts/font = ExtResource("5_dhigr")
theme_override_font_sizes/font_size = 50
theme_override_styles/normal = SubResource("StyleBoxFlat_r114s")
theme_override_styles/hover = SubResource("StyleBoxFlat_t6cof")
theme_override_styles/focus = SubResource("StyleBoxFlat_r1ihh")
theme_override_styles/hover = SubResource("StyleBoxFlat_t6cof")
theme_override_styles/normal = SubResource("StyleBoxFlat_r114s")
text = "Exit the Loop
"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/AnonymousPro-Regular.ttf-208ecbb66c73e515f403
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/Urbanist-Regular.ttf-43977583ef0eb0baed07360c
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
Expand Down
1 change: 1 addition & 0 deletions assets/font/Chunk Five Print.otf.import
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/Chunk Five Print.otf-f633c76f1e29e12672c74edc
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
Expand Down
1 change: 1 addition & 0 deletions assets/font/Creepster-Regular.ttf.import
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/Creepster-Regular.ttf-98d2fff4126ee8dd72a4a54
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
Expand Down
1 change: 1 addition & 0 deletions assets/font/RubikSprayPaint-Regular.ttf.import
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/RubikSprayPaint-Regular.ttf-1fcfff54b87d8e6fd
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
Expand Down
1 change: 1 addition & 0 deletions assets/font/TT_Cometus_Bold-BF63e1cb6288520.ttf.import
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/TT_Cometus_Bold-BF63e1cb6288520.ttf-3a105da78
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
Expand Down
8 changes: 4 additions & 4 deletions assets/tree.obj.import
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ importer="wavefront_obj"
importer_version=1
type="Mesh"
uid="uid://d3ev5x42jk1e5"
path="res://.godot/imported/Tree.obj-6804247cd9b087be4c8f19f0cc3cbfb2.mesh"
path="res://.godot/imported/tree.obj-43c7a77f08ac9559a3f88d96dfd3c78a.mesh"

[deps]

files=["res://.godot/imported/Tree.obj-6804247cd9b087be4c8f19f0cc3cbfb2.mesh"]
files=["res://.godot/imported/tree.obj-43c7a77f08ac9559a3f88d96dfd3c78a.mesh"]

source_file="res://assets/Tree.obj"
dest_files=["res://.godot/imported/Tree.obj-6804247cd9b087be4c8f19f0cc3cbfb2.mesh", "res://.godot/imported/Tree.obj-6804247cd9b087be4c8f19f0cc3cbfb2.mesh"]
source_file="res://assets/tree.obj"
dest_files=["res://.godot/imported/tree.obj-43c7a77f08ac9559a3f88d96dfd3c78a.mesh", "res://.godot/imported/tree.obj-43c7a77f08ac9559a3f88d96dfd3c78a.mesh"]

[params]

Expand Down
14 changes: 10 additions & 4 deletions door_2.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ extends Area3D

func _on_body_entered(body):
if body.name == 'player':
get_tree().change_scene_to_file("res://room_2.tscn")
#get_tree().change_scene_to_file("res://room_2.tscn")
var player = body
GlobalVars.player_world_loc = body.position
GlobalVars.goto_scene("res://room_2.tscn")

func _on_body_exited(body):
if body.name == 'player':
get_tree().change_scene_to_file("res://world.tscn")
#func _on_body_exited(body):
#if body.name == 'player':
##get_tree().change_scene_to_file("res://world.tscn")
#var player = body
#body.position = GlobalVars.player_world_loc
#GlobalVars.goto_scene("res://world.tscn")
5 changes: 3 additions & 2 deletions doors.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ func _on_area3d_body_entered(body):
change_scene()

func change_scene():
var room1_scene = preload("res://room1.tscn")
get_tree().change_scene_to(room1_scene)
#var room1_scene = preload("res://room1.tscn")
#et_tree().change_scene_to(room1_scene)
GlobalVars.goto_scene("res://room1.tscn")
10 changes: 9 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ run/main_scene="res://UI/main_menu.tscn"
config/features=PackedStringArray("4.3", "GL Compatibility")
config/icon="res://icon.svg"

[autoload]

GlobalVars="*res://scripts/global.gd"

[display]

window/size/viewport_width=1280
Expand All @@ -28,12 +32,16 @@ run/main_run_args="Godot_v4.2.1-stable_win64.exe --rendering-driver opengl3"

[editor_plugins]

enabled=PackedStringArray("res://addons/dreadpon.spatial_gardener/plugin.cfg", "res://addons/scene_manager/plugin.cfg")
enabled=PackedStringArray()

[filesystem]

import/fbx/enabled=false

[global_group]

player=""

[input]

up={
Expand Down
6 changes: 5 additions & 1 deletion room1.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=33 format=4 uid="uid://by7d12qshs2rh"]
[gd_scene load_steps=34 format=4 uid="uid://by7d12qshs2rh"]

[ext_resource type="Texture2D" uid="uid://cg4b8a3233ivm" path="res://assets/models/room1/WoodFloor041_1K-JPG/WoodFloor041_1K-JPG_Color.jpg" id="1_5qnk8"]
[ext_resource type="Texture2D" uid="uid://c1jbit7jvdi8i" path="res://assets/models/room1/WoodFloor041_1K-JPG/WoodFloor041_1K-JPG_AmbientOcclusion.jpg" id="2_aq50b"]
Expand All @@ -20,6 +20,7 @@
[ext_resource type="PackedScene" uid="uid://nsyqkx1yvq3c" path="res://attack.tscn" id="18_7w4pu"]
[ext_resource type="Texture2D" uid="uid://bp56787f7tk2m" path="res://assets/models/new_house_House body.jpg" id="19_0tx8o"]
[ext_resource type="Texture2D" uid="uid://4sn1bt5bgbre" path="res://assets/models/new_house_House Bump.jpg" id="20_5caee"]
[ext_resource type="PackedScene" uid="uid://u2dpwucgpafo" path="res://player.tscn" id="21_unx5j"]

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1jfby"]

Expand Down Expand Up @@ -187,3 +188,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.74095, 0.132076, -2.01444)
transform = Transform3D(0.00175047, 0, -0.0999847, 0, 0.1, 0, 0.0999847, 0, 0.00175047, -2.83149, -0.588031, -27.7991)
mesh = SubResource("ArrayMesh_kcfox")
skeleton = NodePath("")

[node name="player" parent="." instance=ExtResource("21_unx5j")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, -0.725598, 0, -5.08224)
6 changes: 5 additions & 1 deletion room_2.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=31 format=4 uid="uid://bciu4aaeii5ly"]
[gd_scene load_steps=32 format=4 uid="uid://bciu4aaeii5ly"]

[ext_resource type="Texture2D" uid="uid://cg4b8a3233ivm" path="res://assets/models/room1/WoodFloor041_1K-JPG/WoodFloor041_1K-JPG_Color.jpg" id="1_8e06u"]
[ext_resource type="Texture2D" uid="uid://c1jbit7jvdi8i" path="res://assets/models/room1/WoodFloor041_1K-JPG/WoodFloor041_1K-JPG_AmbientOcclusion.jpg" id="2_ey8ij"]
Expand All @@ -20,6 +20,7 @@
[ext_resource type="Texture2D" uid="uid://4sn1bt5bgbre" path="res://assets/models/new_house_House Bump.jpg" id="18_j2ewu"]
[ext_resource type="PackedScene" uid="uid://ckheb4m78xdis" path="res://assets/models/psx-low-poly-victorian-clock/source/model.gltf" id="19_rvtp2"]
[ext_resource type="FontFile" uid="uid://dw7kouprdlve2" path="res://assets/font/Chunk Five Print.otf" id="20_x25wv"]
[ext_resource type="PackedScene" uid="uid://u2dpwucgpafo" path="res://player.tscn" id="21_420kj"]

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3rn4t"]

Expand Down Expand Up @@ -198,3 +199,6 @@ theme_override_colors/font_color = Color(0.371818, 0, 0, 1)
theme_override_fonts/font = ExtResource("20_x25wv")
theme_override_font_sizes/font_size = 64
text = "You are safe here!"

[node name="player" parent="." instance=ExtResource("21_420kj")]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0.0982696, 0.516069, -5.09853)
21 changes: 21 additions & 0 deletions scripts/global.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extends Node
var health
var current_scene = null
var player_world_loc : Vector3
var player
func _ready():
var root = get_tree().root
current_scene = root.get_child(root.get_child_count() - 1)
print(root)
func goto_scene(path):
call_deferred("_deferred_goto_scene", path)
func _deferred_goto_scene(path):
current_scene.free()
var s = ResourceLoader.load(path)
current_scene = s.instantiate()
get_tree().root.add_child(current_scene)
get_tree().current_scene = current_scene
player = get_node("/root/" + get_tree().current_scene.name + "/player")

#func _process(delta: float) -> void:
#player = get_node("/root/" + get_tree().current_scene.name + "/player")
Loading