Added Manual Save

This commit is contained in:
MasterGordon 2018-04-08 13:27:52 +02:00
parent aa02d23405
commit 6c04ac3df9
2 changed files with 12 additions and 8 deletions

View File

@ -53,6 +53,7 @@
??? Dollar
</span>
<span style="position: fixed;color: white" id="speed"></span>
<div style="margin-left: 250px"><textarea id="textarea"></textarea><button id="save">save</button><button id="load">load</button></div>
</body>
</html>

View File

@ -23,10 +23,13 @@ var mode = "none"
var renderItems = true
$(document).ready(function() {
$("#speed").click(function() {
$("#save").click(function() {
save()
$("#speed").fadeOut("fast")
$("#speed").fadeIn("fast")
$("#textarea").text(JSON.stringify(game))
})
$("#load").click(function() {
game = JSON.parse($("#textarea").val())
loadGameData()
})
loadGameData()
loadItems()
@ -35,10 +38,10 @@ $(document).ready(function() {
requestAnimationFrame(loop)
})
var game = {}
var game = 0
$(window).on("beforeunload", function() {
save()
//save()
})
function save() {
@ -84,9 +87,9 @@ function loadGameData() {
//Keine Save Vorhanden
factorys.push(new Factory())
inventory = new Inventory()
game = Cookies.get("game")
if (game != undefined) {
game = JSON.parse(game)
//game = Cookies.get("game")
if (game != 0) {
//game = JSON.parse(game)
money = game.money
inventory = new Inventory()
factorys = []