Adding sound and music

This commit is contained in:
2024-09-01 18:16:06 +02:00
parent dfade2fc63
commit 78921a780c
35 changed files with 355 additions and 17 deletions

View File

@@ -5,6 +5,8 @@ signal scanner_selected
func _on_scanner_select_item_selected(index):
var scannerType : Scanners.Type
$ClickSound.play()
match index:
0: scannerType = Scanners.Type.NoScanner
1: scannerType = Scanners.Type.Water

19
scripts/music.gd Normal file
View File

@@ -0,0 +1,19 @@
extends Node
@onready var musics = [
$"Stade Désertique",
$"Stade Intermédiaire",
$"Stade Forestier"
]
var cursor = 1
func _ready():
for player in musics:
player.connect("finished", end_music)
musics[0].play()
func end_music():
musics[min(len(musics) - 1, cursor)].play()
cursor += 1

View File

@@ -42,10 +42,12 @@ func _process(delta: float) -> void:
$AnimatedSprite2D.flip_h = true
func go_to(new_target_pos: Vector2):
$MoveSound.play()
state = MoveState.MOVING
target_pos = new_target_pos
func _on_planting_timeout() -> void:
$PlantSound.play()
Planted.emit()
state = MoveState.IDLE

View File

@@ -27,31 +27,31 @@ void fragment() {
float value = pixel_color.x;
if (dimension == 1) value = pixel_color.y;
if (dimension == 2) value = pixel_color.z;
vec4 color = texture(texture_medium, vert/texture_size);
if (value < texture_low_threshold)
color =
color =
min(
(texture_low_threshold - value) / smooth_change_range,
(texture_low_threshold - value) / smooth_change_range,
1.0
) * texture(texture_low, vert/texture_size)
) * texture(texture_low, vert/texture_size)
+ (1.0 - min(
(texture_low_threshold - value) / smooth_change_range,
(texture_low_threshold - value) / smooth_change_range,
1.0
)
) * texture(texture_medium, vert/texture_size);
if (value > texture_high_threshold)
color =
color =
min(
(value - texture_high_threshold) / smooth_change_range,
(value - texture_high_threshold) / smooth_change_range,
1.0
) * texture(texture_high, vert/texture_size)
) * texture(texture_high, vert/texture_size)
+ (1.0 - min(
(value - texture_high_threshold) / smooth_change_range,
(value - texture_high_threshold) / smooth_change_range,
1.0
)
) * texture(texture_medium, vert/texture_size);
COLOR = color;
}