From 806c39069b1ff78a20f7732da56cc03d5d5e71e4 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Thu, 24 Sep 2020 10:52:58 +0200 Subject: [PATCH] Add pop sound when player adds nodes --- main.gd | 12 ++++++++++++ node.gd | 9 +++++++-- node.tscn | 6 +++++- nodes/pop.wav | Bin 0 -> 9258 bytes nodes/pop.wav.import | 21 +++++++++++++++++++++ repository.gd | 1 - 6 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 nodes/pop.wav create mode 100644 nodes/pop.wav.import diff --git a/main.gd b/main.gd index 319d017..e8c0575 100644 --- a/main.gd +++ b/main.gd @@ -74,6 +74,8 @@ func list_levels(): return final_level_sequence func load_level(id): + AudioServer.set_bus_mute(AudioServer.get_bus_index("Master"), true) + next_level_button.hide() level_congrats.hide() level_description.show() @@ -132,6 +134,16 @@ func load_level(id): game.write_file(win_script_target, win_script_content) terminal.clear() + + # Unmute the audio after a while, so that player can hear pop sounds for + # nodes they create. + var t = Timer.new() + t.wait_time = 3 + add_child(t) + t.start() + yield(t, "timeout") + AudioServer.set_bus_mute(AudioServer.get_bus_index("Master"), false) + # FIXME: Need to clean these up when switching levels somehow. func reload_level(): load_level(current_level) diff --git a/node.gd b/node.gd index 19276b8..6537d88 100644 --- a/node.gd +++ b/node.gd @@ -12,9 +12,14 @@ var hovered = false var arrow = preload("res://arrow.tscn") - func _ready(): - pass +# var t = Timer.new() +# t.wait_time = rand_range(0.0, 0.1) +# add_child(t) +# t.start() +# yield(t, "timeout") + $Pop.pitch_scale = rand_range(0.8, 1.2) + $Pop.play() func _process(_delta): if held: diff --git a/node.tscn b/node.tscn index ccb46f9..4773043 100644 --- a/node.tscn +++ b/node.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://node.gd" type="Script" id=1] [ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2] [ext_resource path="res://nodes/blob.svg" type="Texture" id=3] +[ext_resource path="res://nodes/pop.wav" type="AudioStream" id=4] [sub_resource type="StyleBoxFlat" id=1] content_margin_left = 5.0 @@ -61,5 +62,8 @@ __meta__ = { } [node name="Arrows" type="Node2D" parent="."] + +[node name="Pop" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource( 4 ) [connection signal="mouse_entered" from="Rect" to="." method="_on_hover"] [connection signal="mouse_exited" from="Rect" to="." method="_on_unhover"] diff --git a/nodes/pop.wav b/nodes/pop.wav new file mode 100644 index 0000000000000000000000000000000000000000..30985c770b6214a0fee03e6803440970366ac48d GIT binary patch literal 9258 zcmYkCcUTlj7w)S%%rHX^5|yYVQIZH4K_scDWCRsaP%vlRHSfB*>ni35Dk6dkh$yIt z0nrsy41j_lk_C~>Fihy~>RaFa=iX}_w*tU~&0_bn44cYYb6Z$b?kO9})v_Bnz}@4VxG&s% zu9HjTNVI`7MX$JURK^9NV$KJtp}h!k`|$n%@<->94?2a$p)JS|1)*hVC;AJWMvG7w zT8`$U704Z}LSFdHxo9!sxYbC64&f^gAqw3_#;6q8p+`sueL|LK2;X4<@9p>)G@0Ls z7VrnrzkCTw=BvzY=i#QQ!ztz(UXj3V{}U3tXTQY=O&R z8cc!J@C)pKeXt#B5K`zwOd^gEu|yfMns`h6K@1W*2qBqF=#iO(BUwbuATtPWG8ONy z5pLu?yx&h4kpaXA5lMU_9Eohgoya1_5PuP6(295o^@-O|OdN#I;3jwlu7G=?4x9oT z!2oy+@+Mzn7oKui+i|1fJl%c?ON+ zTah0B8gE~bI?tm@REt{BTO>ulPy=d3ooECRyb2F_Yo0|5`KkP$_%0dz6h57g#&^ER ztAJ#F6lmdB0dr6U)ImCk07|eCOn`p^KX?yB!ya$~TEKVE1Ad0Pp($}0+7kINk}x9D z2_NDCj!8T5oX{cP5H#6FOeP)4DAJh>BUh70$y&02tRwTtr(_NZs9e&9sv-lZW^xtv zlMJWY$z7D3ETkwZnQA2erpn3d)HgDfY9${~gJcHPKyJg=BvYAW3iX6sL0u;oP|2h> zb(FNDwvjs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TEXh7V6ZEz=i3SHn< zOn>ZQ1?a={7nh|m!HG6V%PLJr_EjC zYSxv#mr~FD(^Dmlse2dMToLpepfM9Zlh?Ey_V<5R>{3&V!18e zJY~Hyv8+@!Q`RoKCi9j{WQXL-eh`U588BC6*ipeZ0l+vf4Q48oE>J~kluBF$~ee@daav!D} z@b`S$oqk0J;Uhzo8FtOvsrA_B7Ep7jucRtcC^oLs63GfM}Lz zp~ykhsZyb`S!I!mzKTHQq;QK+OE@Bk5Udn@$I;)48N(OsnTO(NbdsfHD6U4&F!@

**gjwY^Kg4lU<#xS0>N#*gP+DHVakNi@0j7Kph;*qmy4-MAordnxH$GWD`01^ zCz(2C9dm@4!mME=N(V-&v|zfGW=y?u6w|15VhCm;}xiIHQ;o)qufCbpjs{rIbrVHhF0>1d;y<~=Pv=^38s$YpbfkOk724;0euNyA_w<5 zMRpUOVGlWo%XKBrt@BIlDff!&5 zyaCH|xWeD&mtYELg?U*oCaI;U40F}rksGdcYG{Ca!Byi~-bOBx3*am{Tdsv|#zgEk zy9dumHnOvEb|NPGqe=xqK#-Q=FH>JRz%>n z8m8z7vPGBiYK=~mhiv!^WQ|u@g!7~M)4U62-^X|<|ASu)48T?}9h}0?Q31Mv4j%37 zp(gH$c(??f!1MeftcQkJj5EMQp_xx)}b# z)wl!D;vu{DU>U5MBkwa4q05x$VZeT7@xZ@G6uj{QDeYUSMdL174pKINxtU;C$~OHT-?{<_#Oo7wr6PRl<4@=p7RF zzhgU+)~`=WNK9C}7J#I9SMyo_yJog41-$SVcf6@VbDG|;W`%0lLSJY6yDHxP-$h}8 OVJ`nW32*=Z-Tx2Z{QP+U literal 0 HcmV?d00001 diff --git a/nodes/pop.wav.import b/nodes/pop.wav.import new file mode 100644 index 0000000..f7152c5 --- /dev/null +++ b/nodes/pop.wav.import @@ -0,0 +1,21 @@ +[remap] + +importer="wav" +type="AudioStreamSample" +path="res://.import/pop.wav-c45fbac324d41566fc00fa2a6560f011.sample" + +[deps] + +source_file="res://nodes/pop.wav" +dest_files=[ "res://.import/pop.wav-c45fbac324d41566fc00fa2a6560f011.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=false +compress/mode=0 diff --git a/repository.gd b/repository.gd index b499b64..72042fe 100644 --- a/repository.gd +++ b/repository.gd @@ -143,7 +143,6 @@ func apply_forces(): o.position += dir*f o2.position -= dir*f var center_of_gravity = nodes.rect_size/2 - print(center_of_gravity) var d = o.position.distance_to(center_of_gravity) var dir = (o.position - center_of_gravity).normalized() var f = (d+0.00001)*Vector2(0.03, 0.01)