Bläddra i källkod

Autosave every 60 seconds

tags/v0.0.2
Fen Dweller 6 år sedan
förälder
incheckning
89b93b5bb7
2 ändrade filer med 18 tillägg och 5 borttagningar
  1. +2
    -2
      gorge.css
  2. +16
    -3
      gorge.js

+ 2
- 2
gorge.css Visa fil

@@ -341,10 +341,10 @@ button {


.click-popup-info { .click-popup-info {
pointer-events: none; pointer-events: none;
transform-origin: -50% 50%;
text-align: center; text-align: center;
position: fixed; position: fixed;
animation: click-popup-upgrade 2s linear;
transform-origin: 0% 0%;
animation: click-popup-info 2s linear;
animation-fill-mode: both; animation-fill-mode: both;
font-size: 36px; font-size: 36px;
--target: -200px; --target: -200px;


+ 16
- 3
gorge.js Visa fil

@@ -570,7 +570,7 @@ function clickPopup(text, type, location) {
} else if (type == "upgrade") { } else if (type == "upgrade") {
direction = -50; direction = -50;
} else if (type == "info") { } else if (type == "info") {
direction = 50;
direction = 0;
} }


direction *= Math.random() * 0.5 + 1; direction *= Math.random() * 0.5 + 1;
@@ -684,9 +684,24 @@ window.onload = function() {
lastTime = performance.now(); lastTime = performance.now();


setTimeout(updateDisplay, 1000/updateRate); setTimeout(updateDisplay, 1000/updateRate);

setTimeout(autosave, 60000);
}

function autosave() {
saveGame();
let x = window.innerWidth / 2;
let y = window.innerHeight * 9 / 10;
clickPopup("Autosaving...", "info", [x, y]);
setTimeout(autosave, 60000);
} }


function save(e) { function save(e) {
saveGame();
clickPopup("Saved!", "info", [e.clientX, e.clientY]);
}

function saveGame() {
let storage = window.localStorage; let storage = window.localStorage;


storage.setItem("save-version", "0.0.1"); storage.setItem("save-version", "0.0.1");
@@ -696,8 +711,6 @@ function save(e) {
storage.setItem("resources", JSON.stringify(resources)); storage.setItem("resources", JSON.stringify(resources));


storage.setItem("belongings", JSON.stringify(belongings)); storage.setItem("belongings", JSON.stringify(belongings));

clickPopup("Saved!", "upgrade", [e.clientX, e.clientY]);
} }


function load() { function load() {


Laddar…
Avbryt
Spara