| @@ -0,0 +1,29 @@ | |||||
| "use strict"; | |||||
| const buildings = { | |||||
| "micro": { | |||||
| "name": "Micro", | |||||
| "cost": 1e1, | |||||
| "prod": 0.1 | |||||
| }, | |||||
| "anthro": { | |||||
| "name": "Anthro", | |||||
| "cost": 1e2, | |||||
| "prod": 2 | |||||
| }, | |||||
| "car": { | |||||
| "name": "Car", | |||||
| "cost": 1e3, | |||||
| "prod": 5 | |||||
| }, | |||||
| "train": { | |||||
| "name": "Train", | |||||
| "cost": 1e4, | |||||
| "prod": 25 | |||||
| }, | |||||
| "house": { | |||||
| "name": "House", | |||||
| "cost": 1e5, | |||||
| "prod": 100 | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,22 @@ | |||||
| <!DOCTYPE html> | |||||
| <html lang="en"> | |||||
| <head> | |||||
| <meta charset="utf-8"> | |||||
| <title>Gorge</title> | |||||
| <link rel="stylesheet" href="style.css"> | |||||
| <script src="polyfill.js"></script> | |||||
| <script src="constants.js"></script> | |||||
| <script src="numbers.js"></script> | |||||
| <script src="gorge.js"></script> | |||||
| <meta name="theme-color" content="#000000" /> | |||||
| <meta name="description" content="An idle game about eating people" /> | |||||
| <meta property="og:title" content="Stroll" /> | |||||
| <meta property="og:description" content="An idle game about eating people" /> | |||||
| <meta property="og:image" content="https://chemicalcrux.org/gorge.png" /> | |||||
| <link rel="shortcut icon" href="https://chemicalcrux.org/favicon.ico" type="image/x-icon" /> | |||||
| </head> | |||||
| <body> | |||||
| <div id="resource-food">Food: 0</div> | |||||
| </body> | |||||
| @@ -0,0 +1,65 @@ | |||||
| "use strict"; | |||||
| let belongings = {} | |||||
| let resources = { | |||||
| "food": 0 | |||||
| } | |||||
| let updateRate = 60; | |||||
| // setup stuff lol | |||||
| // we'll initialize the dict of buildings we can own | |||||
| function setup() { | |||||
| for (const [key, value] of Object.entries(buildings)) { | |||||
| belongings[key] = {}; | |||||
| belongings[key].count = 0; | |||||
| } | |||||
| console.log(belongings) | |||||
| } | |||||
| function price(type) { | |||||
| return buildings[type].cost * Math.pow(1.02, belongings[type].count) | |||||
| } | |||||
| function calculateProductivity() { | |||||
| let productivity = 0; | |||||
| for (const [key, value] of Object.entries(belongings)) { | |||||
| productivity += productivityOf(key); | |||||
| } | |||||
| return productivity; | |||||
| } | |||||
| // here's where upgrades will go :3 | |||||
| function productivityOf(type) { | |||||
| let baseProd = buildings[type].prod; | |||||
| return baseProd * belongings[type].count; | |||||
| } | |||||
| // update stuff | |||||
| function updateResources() { | |||||
| addResources(); | |||||
| displayResources(); | |||||
| setTimeout(updateResources, 1000/updateRate); | |||||
| } | |||||
| function addResources() { | |||||
| resources.food += calculateProductivity() * 1 / updateRate; | |||||
| } | |||||
| function displayResources() { | |||||
| document.getElementById("resource-food").innerText = "Food: " + render(resources.food); | |||||
| } | |||||
| window.onload = function() { | |||||
| setup(); | |||||
| setTimeout(updateResources, 1000/updateRate); | |||||
| } | |||||
| @@ -0,0 +1,3 @@ | |||||
| function render(val) { | |||||
| return Math.round(val); | |||||
| } | |||||
| @@ -0,0 +1,11 @@ | |||||
| if (!Object.entries) | |||||
| console.log("Your browser doesn't support Object.entries()") | |||||
| Object.entries = function( obj ){ | |||||
| var ownProps = Object.keys( obj ), | |||||
| i = ownProps.length, | |||||
| resArray = new Array(i); // preallocate the Array | |||||
| while (i--) | |||||
| resArray[i] = [ownProps[i], obj[ownProps[i]]]; | |||||
| return resArray; | |||||
| }; | |||||