|
149 | 149 | line-height: 1.3; |
150 | 150 | } |
151 | 151 |
|
| 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 | + |
152 | 165 | @media print { |
153 | 166 | html { |
154 | 167 | font-size: 14px; |
@@ -809,6 +822,17 @@ <h3>Public assets</h3> |
809 | 822 | pop() |
810 | 823 | }</code></pre> |
811 | 824 |
|
| 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 | + |
812 | 836 | <h2><a id="tools">Useful tools</a></h2> |
813 | 837 |
|
814 | 838 | <ul> |
@@ -843,6 +867,8 @@ <h2><a id="tools">Useful tools</a></h2> |
843 | 867 | <script src="prism/prism-typescript.js"></script> |
844 | 868 | <script src="prism/prism-autolinker.js"></script> |
845 | 869 |
|
| 870 | + <script src="js/zzfx.js"></script> |
| 871 | + |
846 | 872 | <script> |
847 | 873 | for (const element of document.querySelectorAll('[data-copy]')) { |
848 | 874 | const data = element.dataset.copy || '' |
@@ -872,10 +898,31 @@ <h2><a id="tools">Useful tools</a></h2> |
872 | 898 | } |
873 | 899 | } |
874 | 900 |
|
| 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 | + |
875 | 919 | /** |
876 | 920 | * @param {HTMLElement} node |
877 | 921 | */ |
878 | 922 | function copyNodeContent(node) { |
| 923 | + if ('https:' !== location.protocol) { |
| 924 | + return alert("Could not copy text: Not in secure context (HTTPS)."); |
| 925 | + }; |
879 | 926 | if (!navigator.clipboard) { |
880 | 927 | return alert("Could not copy text: Unsupported browser."); |
881 | 928 | }; |
|
0 commit comments