From 30ffe51e69abbc9aee6780261a0026b213b77a85 Mon Sep 17 00:00:00 2001 From: v Date: Wed, 31 Mar 2021 03:29:07 +0100 Subject: Add everything and deploy infinite lemons into lemonspace --- game.js | 133 +++++++++++++++++++++++++++++++++++++++++++++++ index.html | 49 +++++++++++++++++ sprites/apioform.png | Bin 0 -> 944 bytes sprites/four.png | Bin 0 -> 3676 bytes sprites/thing.png | Bin 0 -> 970 bytes sprites/undefinedium.png | Bin 0 -> 2305 bytes sprites/violetstar.png | Bin 0 -> 9929 bytes 7 files changed, 182 insertions(+) create mode 100644 game.js create mode 100644 index.html create mode 100644 sprites/apioform.png create mode 100644 sprites/four.png create mode 100644 sprites/thing.png create mode 100644 sprites/undefinedium.png create mode 100644 sprites/violetstar.png diff --git a/game.js b/game.js new file mode 100644 index 0000000..b8e6d32 --- /dev/null +++ b/game.js @@ -0,0 +1,133 @@ +(()=>{ + var root = document.body; + + const cdata = { + thing: { + singular:"thing", + plural:"things", + color:"lime", + }, + apioform: { + singular:"apioform", + plural:"apioforms", + color:"yellow", + }, + violetstar: { + singular:"violet star", + plural:"violet stars", + color:"#8050FF", + }, + undefinedium: { + singular:"undefinedium", + plural:"undefinedium", + color:"#FF00FF", + }, + four: { + singular:"four", + plural:"fours", + color:"#3040FF", + }, + } + + let sdata; + + try { + sdata = JSON.parse(localStorage.savedata); + } catch(e) { + sdata = { + unlocks: {thingbutton:1}, + currencies:{thing:{amount:0,visible:true}}, + }; + } + + let am = sdata.currencies; + + for (let i in cdata){ + if (!am[i]){ + am[i]={amount:0,visible:false}; + } + } + + + var ThingButton = { + view: ()=>{ + return m("button",{onclick:()=>{if (!sdata.autothing) am.thing.amount+=1}},sdata.autothing?"Unavailable":"Attain a thing"); + } + } + + var AutoThing = { + view: ()=>{ + return m("button",{onclick:()=>sdata.autothing = !sdata.autothing},[ + "AutoThing™ ", + m("span",{style:"color:"+(sdata.autothing?"lime":"grey")+";"},sdata.autothing?"ON":"OFF"), + ]); + } + } + let autothing_timeout = "none"; + + setInterval(()=>{localStorage.savedata = JSON.stringify(sdata)},1000); + + var MainComponent = { + view: ()=>{ + let res = [ + m("h1",{style:"text-align:center;"},"Incremental"), + m("hr"), + m(CBar,{data:am}), + ]; + + if (am.thing.amount >= 50) { + am.apioform.visible = true; + sdata.unlocks.autothing = 1; + } + + if (sdata.unlocks.thingbutton) res.push(m(ThingButton)); + if (sdata.unlocks.autothing) res.push(m(AutoThing)); + + if (!sdata.autothing && autothing_timeout != "none"){ + clearInterval(autothing_timeout); + autothing_timeout = "none"; + } + + if (sdata.autothing && autothing_timeout == "none"){ + autothing_timeout = setInterval(()=>{am.thing.amount++;m.redraw()},500); + } + + return m("main",res); + } + } + + var CIcon = { + view: vnode => { + let a = vnode.attrs.currency || "undefinedium"; + a = "sprites/"+a+".png"; + return m("img",{title:cdata[vnode.attrs.currency].plural,src:a,width:32,height:32}); + } + } + + var CDisp = { + view: vnode => { + let a = vnode.attrs; + return m(".currencydisplay",[ + m(CIcon,{currency:a.currency}), + m(".currencycount",{style:"color:"+cdata[a.currency].color},a.amount==undefined?"oh bee something broke":a.amount), + ]); + } + } + + var CBar = { + view: vnode => { + let a = vnode.attrs; + let res = []; + + for (let i in a.data||{}){ + if (a.data[i].visible){ + res.push(m(CDisp,{currency:i,amount:a.data[i].amount})); + } + } + + return m(".currencybar",res); + } + } + + m.mount(root,MainComponent); +})(); diff --git a/index.html b/index.html new file mode 100644 index 0000000..140d1cb --- /dev/null +++ b/index.html @@ -0,0 +1,49 @@ + + + + + + + + + diff --git a/sprites/apioform.png b/sprites/apioform.png new file mode 100644 index 0000000..285011d Binary files /dev/null and b/sprites/apioform.png differ diff --git a/sprites/four.png b/sprites/four.png new file mode 100644 index 0000000..b4ad6bd Binary files /dev/null and b/sprites/four.png differ diff --git a/sprites/thing.png b/sprites/thing.png new file mode 100644 index 0000000..e6f2380 Binary files /dev/null and b/sprites/thing.png differ diff --git a/sprites/undefinedium.png b/sprites/undefinedium.png new file mode 100644 index 0000000..f0d65d7 Binary files /dev/null and b/sprites/undefinedium.png differ diff --git a/sprites/violetstar.png b/sprites/violetstar.png new file mode 100644 index 0000000..1cce452 Binary files /dev/null and b/sprites/violetstar.png differ -- cgit v1.2.3