add sky to train scene
This commit is contained in:
@@ -110,7 +110,7 @@ shader_parameter/sky_bottom_color = Color(0.5, 0.6, 0.7, 1)
|
||||
shader_parameter/gradient_intensity = 1.0
|
||||
shader_parameter/horizon_blend = 0.5
|
||||
shader_parameter/sun_glow_enabled = true
|
||||
shader_parameter/sun_direction = Vector3(0.8560367, 0.48015037, 0.19145952)
|
||||
shader_parameter/sun_direction = Vector3(0.81767046, 0.53474194, 0.21322787)
|
||||
shader_parameter/sun_glow_color = Color(1, 0.95, 0.85, 1)
|
||||
shader_parameter/sun_glow_intensity = 0.3
|
||||
shader_parameter/sun_glow_size = 0.2
|
||||
|
||||
@@ -478,11 +478,11 @@ func _create_debug_panel() -> void:
|
||||
_debug_panel = SkyDebugPanel.new()
|
||||
_debug_panel.name = "SkyDebugPanel"
|
||||
_debug_panel.dynamic_sky = self
|
||||
_debug_panel.anchor_left = 0.0
|
||||
_debug_panel.anchor_left = 1.0
|
||||
_debug_panel.anchor_top = 0.0
|
||||
_debug_panel.anchor_right = 0.0
|
||||
_debug_panel.anchor_right = 1.0
|
||||
_debug_panel.anchor_bottom = 0.0
|
||||
_debug_panel.offset_left = 10.0
|
||||
_debug_panel.offset_left = -310.0
|
||||
_debug_panel.offset_top = 10.0
|
||||
_debug_canvas_layer.add_child(_debug_panel)
|
||||
|
||||
|
||||
@@ -141,10 +141,10 @@ func _create_ui() -> void:
|
||||
_seed_label.text = "Seed: 0 | Day: 1"
|
||||
_vbox.add_child(_seed_label)
|
||||
|
||||
var meteor_button := Button.new()
|
||||
meteor_button.text = "Trigger Meteor Shower"
|
||||
meteor_button.pressed.connect(_on_meteor_pressed)
|
||||
_vbox.add_child(meteor_button)
|
||||
#var meteor_button := Button.new()
|
||||
#meteor_button.text = "Trigger Meteor Shower"
|
||||
#meteor_button.pressed.connect(_on_meteor_pressed)
|
||||
#_vbox.add_child(meteor_button)
|
||||
|
||||
|
||||
func _connect_signals() -> void:
|
||||
|
||||
@@ -80,7 +80,7 @@ custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path=""
|
||||
export_path="web/trinittu.html"
|
||||
patches=PackedStringArray()
|
||||
patch_delta_encoding=false
|
||||
patch_delta_compression_level_zstd=19
|
||||
|
||||
@@ -60,6 +60,16 @@ change_train={
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
horn={
|
||||
"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":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
toggle_debug={
|
||||
"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":4194334,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
|
||||
BIN
resources/japan_river.mp3
Normal file
BIN
resources/japan_river.mp3
Normal file
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://qrf08uiuhyqg"]
|
||||
|
||||
[ext_resource type="AudioStream" uid="uid://bdluyy5uodjb5" path="res://resources/thomastanks_new.mp3" id="1_ht1d5"]
|
||||
[ext_resource type="AudioStream" uid="uid://bf28mghp6mgjx" path="res://resources/japan_river.mp3" id="1_ht1d5"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_ht1d5"]
|
||||
script/source = "extends Node
|
||||
@@ -38,6 +38,6 @@ script = SubResource("GDScript_ht1d5")
|
||||
|
||||
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="." unique_id=281982184]
|
||||
stream = ExtResource("1_ht1d5")
|
||||
volume_db = -5.0
|
||||
volume_db = -4.92
|
||||
autoplay = true
|
||||
parameters/looping = false
|
||||
|
||||
@@ -41,8 +41,8 @@ fog_density = 0.0015
|
||||
script = ExtResource("1_0nial")
|
||||
main_scene = ExtResource("2_7fone")
|
||||
|
||||
[node name="DynamicSky" parent="." unique_id=516593260 instance=ExtResource("3_7brvr")]
|
||||
show_debug_panel = true
|
||||
[node name="DynamicSky" parent="." unique_id=516593260 node_paths=PackedStringArray("weather_vfx") instance=ExtResource("3_7brvr")]
|
||||
weather_vfx = NodePath("WeatherVFX")
|
||||
|
||||
[node name="TrackGenerator" type="Node3D" parent="." unique_id=1804102656]
|
||||
script = ExtResource("2_j07ug")
|
||||
@@ -110,6 +110,8 @@ text = "Comandi:
|
||||
\"A / D - Ruota camera\",
|
||||
\"SPACE - Cambia camera\",
|
||||
\"TAB - Cambia treno\",
|
||||
\"ENTER - Fischio\",
|
||||
\"F3 - Debug Sky\",
|
||||
\"ESC - Esci\""
|
||||
label_settings = SubResource("LabelSettings_tefeu")
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ var distance_traveled: float = 0.0
|
||||
var locomotive: Node3D
|
||||
var wagons: Array = []
|
||||
var wagon_distances: Array = []
|
||||
var _horn_player: AudioStreamPlayer
|
||||
var _horn_playing: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -46,6 +48,7 @@ func _ready() -> void:
|
||||
await get_tree().process_frame
|
||||
_create_train()
|
||||
current_speed = base_speed
|
||||
_create_horn()
|
||||
|
||||
|
||||
func _remove_train():
|
||||
@@ -144,6 +147,9 @@ func _handle_input(delta: float) -> void:
|
||||
elif Input.is_action_pressed("change_train"):
|
||||
_create_train()
|
||||
current_speed = base_speed
|
||||
|
||||
if Input.is_action_just_pressed("horn") and not _horn_playing:
|
||||
_play_horn()
|
||||
|
||||
func _update_movement(delta: float) -> void:
|
||||
distance_traveled += current_speed * delta
|
||||
@@ -187,3 +193,56 @@ func get_locomotive_position() -> Vector3:
|
||||
|
||||
func get_speed() -> float:
|
||||
return current_speed
|
||||
|
||||
|
||||
func _create_horn() -> void:
|
||||
_horn_player = AudioStreamPlayer.new()
|
||||
_horn_player.name = "HornPlayer"
|
||||
_horn_player.volume_db = -6.0
|
||||
_horn_player.bus = "Master"
|
||||
add_child(_horn_player)
|
||||
|
||||
var sample_rate: int = 22050
|
||||
var duration: float = 1.8
|
||||
var num_samples: int = int(sample_rate * duration)
|
||||
var fade_in: float = 0.15
|
||||
var fade_out: float = 0.4
|
||||
|
||||
var freqs: Array[float] = [277.18, 369.99, 311.13]
|
||||
|
||||
var data := PackedByteArray()
|
||||
data.resize(num_samples * 2)
|
||||
|
||||
for i in range(num_samples):
|
||||
var t: float = float(i) / sample_rate
|
||||
var sample: float = 0.0
|
||||
for freq in freqs:
|
||||
sample += sin(TAU * freq * t)
|
||||
sample /= freqs.size()
|
||||
|
||||
var envelope: float = 1.0
|
||||
if t < fade_in:
|
||||
envelope = t / fade_in
|
||||
elif t > duration - fade_out:
|
||||
envelope = (duration - t) / fade_out
|
||||
sample *= envelope
|
||||
|
||||
var value: int = clampi(int(sample * 16000), -32768, 32767)
|
||||
data[i * 2] = value & 0xFF
|
||||
data[i * 2 + 1] = (value >> 8) & 0xFF
|
||||
|
||||
var stream := AudioStreamWAV.new()
|
||||
stream.format = AudioStreamWAV.FORMAT_16_BITS
|
||||
stream.mix_rate = sample_rate
|
||||
stream.data = data
|
||||
_horn_player.stream = stream
|
||||
|
||||
|
||||
func _play_horn() -> void:
|
||||
_horn_playing = true
|
||||
_horn_player.play()
|
||||
_horn_player.finished.connect(_on_horn_finished, CONNECT_ONE_SHOT)
|
||||
|
||||
|
||||
func _on_horn_finished() -> void:
|
||||
_horn_playing = false
|
||||
|
||||
@@ -51,6 +51,11 @@ func _process(_delta: float) -> void:
|
||||
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
SceneSwitcher.switch_scene(main_scene.resource_path)
|
||||
|
||||
if Input.is_action_just_pressed("toggle_debug"):
|
||||
var sky := get_node_or_null("DynamicSky") as DynamicSkyRoot
|
||||
if sky and sky._debug_canvas_layer:
|
||||
sky._debug_canvas_layer.visible = not sky._debug_canvas_layer.visible
|
||||
|
||||
|
||||
func _update_ui() -> void:
|
||||
|
||||
Reference in New Issue
Block a user