Skip to content

Commit

Permalink
Add audio for printing and walking
Browse files Browse the repository at this point in the history
  • Loading branch information
EasyJB committed Aug 15, 2023
1 parent b63b8b3 commit 778e428
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 9 deletions.
4 changes: 2 additions & 2 deletions assets/Music/background_music.mp3.import
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

importer="mp3"
type="AudioStreamMP3"
uid="uid://dmuny5rnmd4t5"
uid="uid://bo5mf8ngttnah"
path="res://.godot/imported/background_music.mp3-9a5b11b7a60a644678b45a62dbee9e99.mp3str"

[deps]
Expand All @@ -12,7 +12,7 @@ dest_files=["res://.godot/imported/background_music.mp3-9a5b11b7a60a644678b45a62

[params]

loop=true
loop=false
loop_offset=0
bpm=0
beat_count=0
Expand Down
2 changes: 1 addition & 1 deletion assets/Music/button_press.wav.import
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

importer="wav"
type="AudioStreamWAV"
uid="uid://cltatxqlm1rwe"
uid="uid://dwhe2pfkl4no8"
path="res://.godot/imported/button_press.wav-66c226ee93ebdfdd3f9de595ec268ac1.sample"

[deps]
Expand Down
Binary file added assets/Music/error_message.wav
Binary file not shown.
24 changes: 24 additions & 0 deletions assets/Music/error_message.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://irbbmpv6hxj5"
path="res://.godot/imported/error_message.wav-eeae734ee797f0f07ca39d0110e78de2.sample"

[deps]

source_file="res://assets/Music/error_message.wav"
dest_files=["res://.godot/imported/error_message.wav-eeae734ee797f0f07ca39d0110e78de2.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file added assets/Music/message.wav
Binary file not shown.
24 changes: 24 additions & 0 deletions assets/Music/message.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://w58qct4jl66x"
path="res://.godot/imported/message.wav-6a8449532007029e5869dd1b313b5abe.sample"

[deps]

source_file="res://assets/Music/message.wav"
dest_files=["res://.godot/imported/message.wav-6a8449532007029e5869dd1b313b5abe.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
Binary file added assets/Music/walking.wav
Binary file not shown.
24 changes: 24 additions & 0 deletions assets/Music/walking.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[remap]

importer="wav"
type="AudioStreamWAV"
uid="uid://bwno3hfnnqkso"
path="res://.godot/imported/walking.wav-d79f43a08e7431e705b11b168b4e40ba.sample"

[deps]

source_file="res://assets/Music/walking.wav"
dest_files=["res://.godot/imported/walking.wav-d79f43a08e7431e705b11b168b4e40ba.sample"]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
1 change: 1 addition & 0 deletions config.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ const DEFAULT_GET_STATE_WAIT_TIME: float = 1.0
const THRESHOLD_OF_SECOND_ROUNDING: float = 0.85
const DELAYS_LIST_SIZE: int = 10
const TICKS_WITHOUT_SYNCHRONIZATION: int = 3
const DEFAULT_ACTION_AUDIO: float = 1.0
3 changes: 3 additions & 0 deletions entity/action/error_log/ErrorLog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ func _init():

func _execute():
self._output_console.print(self._text, Color.DARK_RED)
var audio = get_node("/root/Scene/AudioEffect")
audio.stream = load("res://assets/Music/error_message.wav")
audio.play()
1 change: 1 addition & 0 deletions entity/action/message_log/MessageLog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ func _execute():

# count down to when it is stopped being shown
object.speech_bubble.get_node("VisibilityTimer").start(1)

3 changes: 2 additions & 1 deletion entity/action/move/Move.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ func _execute():
object.get_node("AnimatedSprite2D").set_animation(animation)
object.get_node("AnimatedSprite2D").play()
object.get_node("AnimatedSprite2D").set_frame(0)

object.get_node("AnimationEffect").stream = load("res://assets/Music/walking.wav")
object.get_node("AnimationEffect").play()

await object.move(Vector2i(object._position) + Vector2i(self._direction), (Globals.DEFAULT_ACTION_SPEED - 0.1) / Globals.ACTION_SPEED_MULTIPLIER)

Expand Down
4 changes: 4 additions & 0 deletions entity/action/print/Print.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ func _init():

func _execute():
self._output_console.print(self._text, Color.WHITE)
var audio = get_node("/root/Scene/AudioEffect")
audio.stream = load("res://assets/Music/message.wav")
audio.play()

5 changes: 5 additions & 0 deletions entity/object/agent/agent.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,8 @@ action_speed = 1.0
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_6onvm")
animation = &"walk_down"

[node name="AnimationEffect" type="AudioStreamPlayer2D" parent="."]
volume_db = -15.0
max_distance = 100.0
attenuation = 1.07177
1 change: 1 addition & 0 deletions globals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ var DEFAULT_ACTION_SPEED: float = 0.5
var ACTION_SPEED_MULTIPLIER: int
var OBJECTS_IN_CREATION: Array[int] = []
var BUSY_HTTP_STATUSES: Array[int] = [HTTPClient.STATUS_CONNECTING, HTTPClient.STATUS_REQUESTING]

5 changes: 4 additions & 1 deletion scene.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[ext_resource type="Script" path="res://scene/MapPopulator.gd" id="7_jlnul"]
[ext_resource type="Script" path="res://scene/ObjectsContainer.gd" id="7_ol1bq"]
[ext_resource type="Script" path="res://scene/TooltipsUpdater.gd" id="8_j32hx"]
[ext_resource type="AudioStream" uid="uid://dmuny5rnmd4t5" path="res://assets/Music/background_music.mp3" id="12_emngv"]
[ext_resource type="AudioStream" uid="uid://bo5mf8ngttnah" path="res://assets/Music/background_music.mp3" id="12_emngv"]

[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_71a80"]
texture = ExtResource("2_m0xfg")
Expand Down Expand Up @@ -532,6 +532,9 @@ stream = ExtResource("12_emngv")
volume_db = -40.31
autoplay = true

[node name="AudioEffect" type="AudioStreamPlayer" parent="."]
volume_db = -15.0

[connection signal="create_agent_requested" from="CanvasLayer/UI" to="AgentCreator" method="_on_ui_create_agent_requested"]
[connection signal="disable_camera_movement" from="CanvasLayer/UI" to="Camera2D" method="_on_ui_disable_camera_movement"]
[connection signal="enable_camera_movement" from="CanvasLayer/UI" to="Camera2D" method="_on_ui_enable_camera_movement"]
Expand Down
8 changes: 5 additions & 3 deletions scene/world_updater/StateGetter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ func _speed_up_actions():
for object in Globals.WORLD_UPDATER.objects_container.get_children():
object.execute_action_timer.wait_time = Globals.DEFAULT_ACTION_SPEED / Globals.ACTION_SPEED_MULTIPLIER
object.get_node("AnimatedSprite2D").speed_scale = Globals.ACTION_SPEED_MULTIPLIER

func _handle_lag(old_tick_number, new_tick_number):
var old_action_speed_multiplier = Globals.ACTION_SPEED_MULTIPLIER
var action_audio_node = get_node("/root/entity/object/Agent/AnimationEffect")
Globals.ACTION_SPEED_MULTIPLIER = 1 if new_tick_number <= old_tick_number else new_tick_number - old_tick_number

action_audio_node.pitch_scale = Config.DEFAULT_ACTION_AUDIO
if old_action_speed_multiplier != Globals.ACTION_SPEED_MULTIPLIER:
action_audio_node.pitch_scale = Config.DEFAULT_ACTION_AUDIO / Globals.ACTION_SPEED_MULTIPLIER
_speed_up_actions()

func _update_state(response):
if "scene" in response.keys():
json.parse(response["scene"])
Expand Down
2 changes: 1 addition & 1 deletion ui.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[ext_resource type="Script" path="res://OutputConsole.gd" id="4_rw6m0"]
[ext_resource type="Script" path="res://ui/Settings.gd" id="4_ss325"]
[ext_resource type="Script" path="res://ui/Tooltips.gd" id="5_fyncs"]
[ext_resource type="AudioStream" uid="uid://cltatxqlm1rwe" path="res://assets/Music/button_press.wav" id="7_e7dui"]
[ext_resource type="AudioStream" uid="uid://dwhe2pfkl4no8" path="res://assets/Music/button_press.wav" id="7_e7dui"]

[sub_resource type="CodeHighlighter" id="CodeHighlighter_2lklk"]

Expand Down

0 comments on commit 778e428

Please sign in to comment.