summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorv <heavpoot@gmail.com>2021-03-31 03:29:07 +0100
committerv <heavpoot@gmail.com>2021-03-31 03:29:07 +0100
commit30ffe51e69abbc9aee6780261a0026b213b77a85 (patch)
treebca77bbc67d29066a26c4e5bf0b0327bbd426a60
Add everything and deploy infinite lemons into lemonspace
-rw-r--r--game.js133
-rw-r--r--index.html49
-rw-r--r--sprites/apioform.pngbin0 -> 944 bytes
-rw-r--r--sprites/four.pngbin0 -> 3676 bytes
-rw-r--r--sprites/thing.pngbin0 -> 970 bytes
-rw-r--r--sprites/undefinedium.pngbin0 -> 2305 bytes
-rw-r--r--sprites/violetstar.pngbin0 -> 9929 bytes
7 files changed, 182 insertions, 0 deletions
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 @@
+<html>
+ <head>
+ <style>
+ body {
+ color:#FFF;
+ background-color:#112;
+ margin-left:auto;
+ margin-right:auto;
+ max-width:80ch;
+ font-family:monospace;
+ font-size:1.5rem;
+ }
+ button {
+ background-color:#000;
+ color:#fff;
+ font-family:monospace;
+ font-size:1.5rem;
+ }
+ .currencydisplay {
+ height:32px;
+ display:inline-flex;
+ align-items:end;
+ }
+ .currencydisplay img {
+ display:inline;
+ margin:0;
+ padding:0;
+ }
+ .currencycount {
+ display:inline-block;
+ margin-left:10px;
+ }
+ .currencybar .currencycount {
+ margin-right:20px;
+ }
+
+ .currencybar {
+ display:flex;
+ border:2px solid white;
+ margin-bottom:5px;
+ background-color:#222;
+ }
+ </style>
+ </head>
+ <body>
+ <script src="https://unpkg.com/mithril/mithril.js"></script>
+ <script src="game.js"></script>
+ </body>
+</html>
diff --git a/sprites/apioform.png b/sprites/apioform.png
new file mode 100644
index 0000000..285011d
--- /dev/null
+++ b/sprites/apioform.png
Binary files differ
diff --git a/sprites/four.png b/sprites/four.png
new file mode 100644
index 0000000..b4ad6bd
--- /dev/null
+++ b/sprites/four.png
Binary files differ
diff --git a/sprites/thing.png b/sprites/thing.png
new file mode 100644
index 0000000..e6f2380
--- /dev/null
+++ b/sprites/thing.png
Binary files differ
diff --git a/sprites/undefinedium.png b/sprites/undefinedium.png
new file mode 100644
index 0000000..f0d65d7
--- /dev/null
+++ b/sprites/undefinedium.png
Binary files differ
diff --git a/sprites/violetstar.png b/sprites/violetstar.png
new file mode 100644
index 0000000..1cce452
--- /dev/null
+++ b/sprites/violetstar.png
Binary files differ