diff --git a/project.godot b/project.godot index 7a86978..ac520d3 100644 --- a/project.godot +++ b/project.godot @@ -4,7 +4,7 @@ config_version=5 [application] config/name="DauphinCraft" config/description="Minecraft-like sous-marin — joue un dauphin" -run/main_scene="res://scenes/Main.tscn" +run/main_scene="res://scenes/MainMenu.tscn" config/features=PackedStringArray("4.6", "Forward Plus") config/icon="res://icon.svg" diff --git a/scenes/Main.tscn b/scenes/Main.tscn index 8193102..7f81f11 100644 --- a/scenes/Main.tscn +++ b/scenes/Main.tscn @@ -1,14 +1,29 @@ -[gd_scene load_steps=3 format=3] +[gd_scene load_steps=6 format=3 uid="uid://dauphincraft_main"] -[sub_resource type="SphereMesh" id="SphereMesh_1"] +[ext_resource type="Script" path="res://scripts/Main.gd" id="1_mainscript"] +[ext_resource type="Script" path="res://scripts/ambience/UnderwaterEnvironment.gd" id="2_uwenv"] +[ext_resource type="PackedScene" path="res://scenes/World.tscn" id="3_world"] +[ext_resource type="PackedScene" path="res://scenes/Dolphin.tscn" id="4_dolphin"] +[ext_resource type="Script" path="res://scripts/ambience/PlanktonParticles.gd" id="5_plankton"] [node name="Main" type="Node3D"] +script = ExtResource("1_mainscript") -[node name="Camera3D" type="Camera3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 5) +[node name="UnderwaterEnvironment" type="WorldEnvironment" parent="."] +script = ExtResource("2_uwenv") -[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 0.707, 0.707, 0, -0.707, 0.707, 0, 3, 0) +[node name="SunLight" type="DirectionalLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.342, 0.940, 0, -0.940, 0.342, 0, 60, 0) +light_color = Color(0.6, 0.85, 1.0, 1) +light_energy = 1.2 +shadow_enabled = true -[node name="Sphere" type="MeshInstance3D" parent="."] -mesh = SubResource("SphereMesh_1") +[node name="World" parent="." instance=ExtResource("3_world")] + +[node name="Dolphin" parent="." instance=ExtResource("4_dolphin")] +position = Vector3(0, 55, 0) + +[node name="PlanktonFollower" type="Node3D" parent="."] + +[node name="PlanktonParticles" type="GPUParticles3D" parent="PlanktonFollower"] +script = ExtResource("5_plankton") diff --git a/scripts/Main.gd b/scripts/Main.gd new file mode 100644 index 0000000..a45234e --- /dev/null +++ b/scripts/Main.gd @@ -0,0 +1,42 @@ +extends Node3D + +@onready var world: Node3D = $World/ChunkManager +@onready var dolphin: CharacterBody3D = $Dolphin +@onready var hud: CanvasLayer = $Dolphin/HUD +@onready var plankton_follower: Node3D = $PlanktonFollower + + +func _ready() -> void: + dolphin.block_break_requested.connect(_on_block_break) + dolphin.block_place_requested.connect(_on_block_place) + dolphin.echolocation_triggered.connect(_on_echolocation) + + if is_instance_valid(hud) and hud.has_method("connect_to_dolphin"): + hud.connect_to_dolphin(dolphin) + + AudioManager.play_ambient_loop("underwater_ambient") + AudioManager.play_music("underwater_theme") + AudioManager.play_whale_call_random() + + world.world_seed = 12345 + + +func _process(_delta: float) -> void: + world.update_player_position(dolphin.global_position) + plankton_follower.global_position = dolphin.global_position + + +func _on_block_break(hit_position: Vector3, _normal: Vector3) -> void: + var broken_id := world.break_block(hit_position) + if broken_id > 0: + AudioManager.play_bubble_sfx(hit_position) + + +func _on_block_place(hit_position: Vector3, normal: Vector3) -> void: + var place_pos := hit_position + normal * 0.5 + var current_selected_block := 2 + world.place_block(place_pos, current_selected_block) + + +func _on_echolocation(position: Vector3, _radius: float) -> void: + AudioManager.play_bubble_sfx(position)