Mae's website :3 maemoon.me
personal website svelte sveltekit
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix whitespace

+8 -43
+2 -2
src/routes/experiments/click/+page.svelte
··· 1 1 <script> 2 - import Codedisplay from "./lib/codedisplay.svelte"; 2 + import CodeDisplay from "./lib/codeDisplay.svelte"; 3 3 4 4 let game = $state({ 5 5 score: 0, ··· 54 54 <button class="button" onclick={upgradeAuto}>upgradeAuto();</button> 55 55 {/if} 56 56 </div> 57 - <Codedisplay {game}></Codedisplay> 57 + <CodeDisplay {game}></CodeDisplay> 58 58 59 59 <style> 60 60 .buttons {
+6 -41
src/routes/experiments/click/lib/codedisplay.svelte
··· 3 3 4 4 let code = $derived.by(() => { 5 5 // Header 6 - let codeString = `// click v0.1 7 - // by Mae Moon 8 - // TODO: add saving\n\n`; 6 + let codeString = `// click v0.1\n// by Mae Moon\n// TODO: add saving\n\n`; 9 7 // Click 10 8 if (game.featuresUnlocked.includes(1)) { 11 - codeString += `function click() { 12 - score += ${game.clickPower}; 13 - // TODO: add new stuff 14 - }` 9 + codeString += `function click() {\n score += ${game.clickPower};\n // TODO: add new stuff\n}`; 15 10 } else if (game.featuresUnlocked.includes(0)) { 16 - codeString += `function click() { 17 - score += ${game.clickPower}; 18 - if (score >= 300) { 19 - unlockNewFeature(); 20 - } 21 - }` 11 + codeString += `function click() {\n score += ${game.clickPower};\n if (score >= 300) {\n unlockNewFeature();\n }\n}`; 22 12 } else { 23 - codeString += `function click() { 24 - score += ${game.clickPower}; 25 - if (score >= 25) { 26 - unlockNewFeature(); 27 - } 28 - }` 13 + codeString += `function click() {\n score += ${game.clickPower};\n if (score >= 25) {\n unlockNewFeature();\n }\n}`; 29 14 } 30 15 31 16 // Click Upgrade 32 17 if (game.featuresUnlocked.includes(0)) { 33 - codeString += ` 34 - function upgrade() { 35 - if (score >= ${game.upgradePrice}) { 36 - score -= ${game.upgradePrice}; 37 - clickPower += 1; 38 - upgradePrice *= 2; 39 - } 40 - }` 18 + codeString += `\n\nfunction upgrade() {\n if (score >= ${game.upgradePrice}) {\n score -= ${game.upgradePrice};\n clickPower += 1;\n upgradePrice *= 2;\n }\n}`; 41 19 } 42 20 43 21 // Autoclicker 44 22 if (game.featuresUnlocked.includes(1)) { 45 - codeString += ` 46 - function upgradeAuto() { 47 - if (score >= ${game.autoUpgradePrice}) { 48 - score -= ${game.autoUpgradePrice}; 49 - autoclickPower += 1; 50 - autoUpgradePrice *= 3; 51 - } 52 - } 53 - 54 - function autoclick() { 55 - score += ${game.autoclickPower}; 56 - } 57 - 58 - setInterval(autoclick, 1000);` 23 + codeString += `\n\nfunction upgradeAuto() {\n if (score >= ${game.autoUpgradePrice}) {\n score -= ${game.autoUpgradePrice};\n autoclickPower += 1;\n autoUpgradePrice *= 3;\n }\n}\n\nfunction autoclick() {\n score += ${game.autoclickPower};\n}\n\nsetInterval(autoclick, 1000);`; 59 24 } 60 25 return codeString; 61 26 });