43 lines
912 B
JavaScript
43 lines
912 B
JavaScript
function exportSaveState() {
|
|
var state = {};
|
|
|
|
if(gameState == 1 || gameState == -1 || (gameState === 0 && localStorage.getItem('saveState') !== undefined)) {
|
|
state = {
|
|
clock: $.extend(true, {}, MainClock),
|
|
blocks: $.extend(true, [], blocks),
|
|
score: score,
|
|
wavegen: waveone,
|
|
gdx: gdx,
|
|
gdy: gdy,
|
|
comboMultiplier:comboMultiplier
|
|
};
|
|
|
|
state.clock.blocks.map(function(a){
|
|
for (var i = 0; i < a.length; i++) {
|
|
a[i] = $.extend(true, {}, a[i]);
|
|
}
|
|
|
|
a.map(descaleBlock);
|
|
});
|
|
|
|
for (var i = 0; i < state.blocks.length; i++) {
|
|
state.blocks[i] = $.extend(true, {}, state.blocks[i]);
|
|
}
|
|
|
|
state.blocks.map(descaleBlock);
|
|
}
|
|
|
|
return JSONfn.stringify(state);
|
|
}
|
|
|
|
function descaleBlock(b) {
|
|
b.distFromHex /= settings.scale;
|
|
}
|
|
|
|
function clearSaveState() {
|
|
localStorage.setItem("saveState", "{}");
|
|
}
|
|
|
|
function isStateSaved() {
|
|
return localStorage.getItem("saveState") != "{}";
|
|
}
|