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 ??? Dollar
</span> </span>
<span style="position: fixed;color: white" id="speed"></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> </body>
</html> </html>

View File

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