Skip to content

Commit 54e4199

Browse files
committed
add sfx samples
1 parent 62b3bbc commit 54e4199

File tree

7 files changed

+3641
-2265
lines changed

7 files changed

+3641
-2265
lines changed

public/about.html

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@
149149
line-height: 1.3;
150150
}
151151

152+
#sfx-list button {
153+
margin-left: 0.5em;
154+
padding: 0.5em 1em;
155+
border: 1px solid rgba(0,0,0,.5);
156+
}
157+
#sfx-list {
158+
overflow-x: auto;
159+
}
160+
#sfx-list strong {
161+
display: inline-block;
162+
margin-right: 0.5em;
163+
}
164+
152165
@media print {
153166
html {
154167
font-size: 14px;
@@ -809,6 +822,17 @@ <h3>Public assets</h3>
809822
pop()
810823
}</code></pre>
811824

825+
<h2>Sound Effect Samples</h2>
826+
827+
<ul id="sfx-list">
828+
<li><strong>Jump:</strong><code>sfx([,,392,,.03,.12,1,3.6,,69,,,,,,,,.95,.1])</code></li>
829+
<li><strong>Coin:</strong><code>sfx([,,1675,,.06,.24,1,1.82,,,837,.06])</code></li>
830+
<li><strong>Bounce:</strong><code>sfx([2,.8,999,,,,,1.5,,.3,-99,.1,1.63,,,.11,.22])</code></li>
831+
<li><strong>Explosion:</strong><code>sfx([,,333,.01,0,.9,4,1.9,,,,,,.5,,.6])</code></li>
832+
<li><strong>Attack:</strong><code>sfx([,,150,.05,,.05,,1.3,,,,,,3])</code></li>
833+
<li><strong>Damage:</strong><code>sfx([,,537,.02,.02,.22,1,1.59,-6.98,4.97])</code></li>
834+
</ul>
835+
812836
<h2><a id="tools">Useful tools</a></h2>
813837

814838
<ul>
@@ -843,6 +867,8 @@ <h2><a id="tools">Useful tools</a></h2>
843867
<script src="prism/prism-typescript.js"></script>
844868
<script src="prism/prism-autolinker.js"></script>
845869

870+
<script src="js/zzfx.js"></script>
871+
846872
<script>
847873
for (const element of document.querySelectorAll('[data-copy]')) {
848874
const data = element.dataset.copy || ''
@@ -872,10 +898,31 @@ <h2><a id="tools">Useful tools</a></h2>
872898
}
873899
}
874900

901+
const sfx = (arr) => zzfx(...arr)
902+
for (const item of document.querySelectorAll('#sfx-list li code')) {
903+
const btnPlay = document.createElement('button')
904+
btnPlay.textContent = '▶️'
905+
btnPlay.onclick = () => eval(item.textContent)
906+
907+
const btnCopy = document.createElement('button')
908+
btnCopy.textContent = '📄'
909+
btnCopy.onclick = () => {
910+
selectNodeContent(item)
911+
copyNodeContent(item)
912+
}
913+
914+
item.parentElement.append(document.createElement('br'))
915+
item.parentElement.append(btnPlay)
916+
item.parentElement.append(btnCopy)
917+
}
918+
875919
/**
876920
* @param {HTMLElement} node
877921
*/
878922
function copyNodeContent(node) {
923+
if ('https:' !== location.protocol) {
924+
return alert("Could not copy text: Not in secure context (HTTPS).");
925+
};
879926
if (!navigator.clipboard) {
880927
return alert("Could not copy text: Unsupported browser.");
881928
};
File renamed without changes.

0 commit comments

Comments
 (0)