From e53abdfe8ccd11f8589ac4b6aef5ae916cd65901 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 31 Aug 2022 03:13:47 +0600 Subject: initialize the preferences and save&load system --- core/src/com/ilotterytea/maxoning/MaxonGame.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'core/src/com/ilotterytea/maxoning/MaxonGame.java') diff --git a/core/src/com/ilotterytea/maxoning/MaxonGame.java b/core/src/com/ilotterytea/maxoning/MaxonGame.java index 84bc6e6..ee59fa9 100644 --- a/core/src/com/ilotterytea/maxoning/MaxonGame.java +++ b/core/src/com/ilotterytea/maxoning/MaxonGame.java @@ -1,13 +1,20 @@ package com.ilotterytea.maxoning; import com.badlogic.gdx.Game; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Preferences; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.ilotterytea.maxoning.player.MaxonPlayer; import com.ilotterytea.maxoning.screens.AssetLoadingScreen; +import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; + +import java.io.IOException; public class MaxonGame extends Game { public SpriteBatch batch; public AssetManager assetManager; + public Preferences prefs; private static MaxonGame instance; @@ -21,8 +28,18 @@ public class MaxonGame extends Game { @Override public void create () { batch = new SpriteBatch(); + prefs = Gdx.app.getPreferences("Maxoning"); + + if (!GameDataSystem.exists()) { + try { + GameDataSystem.SaveData(new MaxonPlayer()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } assetManager = new AssetManager(); + this.setScreen(new AssetLoadingScreen(this)); } @@ -40,4 +57,8 @@ public class MaxonGame extends Game { assetManager.dispose(); instance.dispose(); } + + public void registerItems() { + + } } -- cgit v1.2.3