hextris/js/save-state.js
2014-06-23 23:12:38 -04:00

28 lines
681 B
JavaScript

function exportSaveState() {
var state = {};
if(gameState == 1 || gameState == -1 || (gameState == 0 && localStorage.getItem('saveState') !== undefined)) {
debugger
MainClock.blocks.map(function(block){block.distFromHex /= settings.scale});
blocks.map(function(block){block.distFromHex /= settings.scale})
state = {
clock: MainClock,
blocks: blocks,
score: score,
wavegen: waveone,
gdx: gdx,
gdy: gdy,
comboMultiplier:comboMultiplier
}
}
return JSONfn.stringify(state);
}
function clearSaveState() {
localStorage.setItem("saveState", "{}");
}
function isStateSaved() {
return localStorage.getItem("saveState") != "{}";
}