diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..e69de29 diff --git a/icon.svg b/icon.svg deleted file mode 100644 index 9d8b7fa..0000000 --- a/icon.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/icon.svg.import b/icon.svg.import deleted file mode 100644 index d22c5a1..0000000 --- a/icon.svg.import +++ /dev/null @@ -1,37 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://cmoqyf6xfwvl7" -path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://icon.svg" -dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 -svg/scale=1.0 -editor/scale_with_editor_scale=false -editor/convert_colors_with_editor_theme=false diff --git a/project.godot b/project.godot index 72c2865..59b70ee 100644 --- a/project.godot +++ b/project.godot @@ -13,7 +13,8 @@ config_version=5 config/name="Hotel Madness" run/main_scene="res://start.tscn" config/features=PackedStringArray("4.3", "Forward Plus") -config/icon="res://icon.svg" +boot_splash/bg_color=Color(0, 0, 0, 1) +boot_splash/show_image=false [autoload] @@ -73,6 +74,35 @@ window/size/viewport_height=600 window/stretch/mode="canvas_items" window/stretch/aspect="expand" +[input] + +move_forwards={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null) +] +} +move_backwards={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null) +] +} +move_left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null) +] +} +move_right={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null) +] +} +jump={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) +] +} + [rendering] +textures/vram_compression/import_etc2_astc=true environment/defaults/default_clear_color=Color(0, 0, 0, 1) diff --git a/scenes/entities/player.tscn b/scenes/entities/player.tscn index cd40b3d..f0d4c5c 100644 --- a/scenes/entities/player.tscn +++ b/scenes/entities/player.tscn @@ -16,3 +16,4 @@ mesh = SubResource("CapsuleMesh_yly5q") shape = SubResource("CapsuleShape3D_7frjr") [node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0) diff --git a/scenes/maps/testmap.tscn b/scenes/maps/testmap.tscn index 716da5f..97ef0c4 100644 --- a/scenes/maps/testmap.tscn +++ b/scenes/maps/testmap.tscn @@ -1,6 +1,9 @@ -[gd_scene load_steps=2 format=3 uid="uid://cbyee7drds7qu"] +[gd_scene load_steps=4 format=3 uid="uid://cbyee7drds7qu"] [ext_resource type="Script" path="res://scripts/maps/map.gd" id="1_4npcs"] +[ext_resource type="PackedScene" uid="uid://bsghm187n6ykx" path="res://scenes/objects/closet.tscn" id="2_yvpvm"] + +[sub_resource type="Environment" id="Environment_pq0iv"] [node name="Testmap" type="Node3D"] script = ExtResource("1_4npcs") @@ -20,9 +23,11 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 16, 4, 0) [node name="2" type="Node3D" parent="PlayerSpawn"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 15) -[node name="Camera3D" type="Camera3D" parent="."] -transform = Transform3D(0.707107, -0.353553, 0.612372, 0, 0.866025, 0.5, -0.707107, -0.353553, 0.612372, 43, 20, 43) -current = true - [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] -transform = Transform3D(-0.965926, 0.258819, 0, -0.224144, -0.836516, 0.5, 0.12941, 0.482963, 0.866025, 0, 0, 0) +transform = Transform3D(-0.899519, 0.375, 0.224144, -0.224144, -0.836516, 0.5, 0.375, 0.399519, 0.836516, 0, 0, 0) + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_pq0iv") + +[node name="Closet" parent="." instance=ExtResource("2_yvpvm")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 10, 2) diff --git a/scenes/objects/closet.tscn b/scenes/objects/closet.tscn new file mode 100644 index 0000000..3794920 --- /dev/null +++ b/scenes/objects/closet.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=3 uid="uid://bsghm187n6ykx"] + +[sub_resource type="BoxMesh" id="BoxMesh_qilbd"] +size = Vector3(1, 2, 1) + +[sub_resource type="BoxShape3D" id="BoxShape3D_by26a"] +size = Vector3(1, 2, 1) + +[node name="Closet" type="RigidBody3D"] + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +mesh = SubResource("BoxMesh_qilbd") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +shape = SubResource("BoxShape3D_by26a") diff --git a/scripts/entities/player.gd b/scripts/entities/player.gd index 2c03047..a701bf8 100644 --- a/scripts/entities/player.gd +++ b/scripts/entities/player.gd @@ -22,10 +22,10 @@ func _physics_process(delta: float) -> void: if not is_on_floor(): velocity += get_gravity() * delta - if Input.is_action_just_pressed("ui_accept") and is_on_floor(): + if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = JUMP_VELOCITY - var input_dir: Vector2 = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") + var input_dir: Vector2 = Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards") var direction: Vector3 = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() if direction: diff --git a/scripts/utils/log.gd b/scripts/utils/log.gd index ef0a21c..6d498ad 100644 --- a/scripts/utils/log.gd +++ b/scripts/utils/log.gd @@ -13,7 +13,7 @@ func error(message: String, alert_message: String) -> void: if OS.shell_open(OS.get_user_data_dir()) != OK: Log.warning("Couldn't open file explorer!") else: - OS.alert("An error has occured. The program will now exit.", "Error!") + OS.alert("An error has occurred. The program will now exit.", "Error!") get_tree().quit() mutex.unlock() diff --git a/scripts/utils/networking.gd b/scripts/utils/networking.gd index b092c2f..a7ee36b 100644 --- a/scripts/utils/networking.gd +++ b/scripts/utils/networking.gd @@ -16,7 +16,6 @@ func _ready() -> void: Log.error("FAILED to connect the peer_disconnected signal to _on_peer_disconnected!", "Internal Error: Failed to connect signal.") if playerlist_changed.connect(_on_playerlist_changed) != OK: Log.error("FAILED to connect the playerlist_changed signal to _on_playerlist_changed!", "Internal Error: Failed to connect signal.") - func _on_playerlist_changed() -> void: pass @@ -44,6 +43,7 @@ func join_server() -> Error: # Close all network connections. func close_network() -> void: multiplayer.multiplayer_peer = null + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) Log.info("Closed all network connections.") ## Matchmaking Code @@ -151,8 +151,7 @@ func peer_disconnected_message(id: int) -> void: Log.warning("Couldn't emit playerlist_changed signal.") return Log.info("Peer %d successfully removed." % id) - - + # This is the initial server response, which tells the client what its role is. @rpc("authority", "call_remote", "reliable") func server_response(status: int, manager: int) -> void: @@ -217,7 +216,7 @@ func request_playerlist(peername: String) -> void: Log.warning("Couldn't send failure response to peer %d!" % multiplayer.get_remote_sender_id()) Log.warning("Peer %d tried to send this client a request meant for the room host!" % multiplayer.get_remote_sender_id()) -# Recive the playerlist on the client. +# Receive the playerlist on the client. @rpc("any_peer", "call_remote", "reliable") func send_playerlist(status: int, newPeers: Dictionary) -> void: if multiplayer.get_remote_sender_id() == managerID: @@ -229,7 +228,7 @@ func send_playerlist(status: int, newPeers: Dictionary) -> void: Log.error("Couldn't change to the lobby scene! Closing application.", "Couldn't change to the lobby scene!") 1: peers = newPeers - Log.debug("Playerlist recived.") + Log.debug("Playerlist received.") if emit_signal("playerlist_changed") != OK: Log.warning("Couldn't emit playerlist_changed signal.") 2: @@ -265,10 +264,11 @@ func start_game() -> void: func player_sync_call(position: Vector3, rotation: Vector3) -> void: for peer: int in Networking.get_ids(): - if rpc_id(peer, "player_sync", position, rotation) != OK: - Log.warning("Couldn't send RPC to %d!" % peer) + if peer != multiplayer.get_unique_id(): + if rpc_id(peer, "player_sync", position, rotation) != OK: + Log.warning("Couldn't send RPC to %d!" % peer) -# Starts the game. +# Synchronizes the player state. @rpc("any_peer", "call_local", "reliable") func player_sync(position: Vector3, rotation: Vector3) -> void: if verify_id(multiplayer.get_remote_sender_id()):