From bab2b2f6d21d41e446342683d4351575b37d3f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 27 Jan 2016 22:24:30 +0100 Subject: add Backend, DesktopBackend, AndroidBackend --- .../ch/asynk/rustanddust/android/AndroidBackend.java | 15 +++++++++++++++ .../ch/asynk/rustanddust/android/AndroidLauncher.java | 17 ++++++++++------- core/src/ch/asynk/rustanddust/Backend.java | 5 +++++ core/src/ch/asynk/rustanddust/RustAndDust.java | 6 ++++++ .../ch/asynk/rustanddust/desktop/DesktopBackend.java | 10 ++++++++++ .../ch/asynk/rustanddust/desktop/DesktopLauncher.java | 2 +- 6 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 android/src/ch/asynk/rustanddust/android/AndroidBackend.java create mode 100644 core/src/ch/asynk/rustanddust/Backend.java create mode 100644 desktop/src/ch/asynk/rustanddust/desktop/DesktopBackend.java diff --git a/android/src/ch/asynk/rustanddust/android/AndroidBackend.java b/android/src/ch/asynk/rustanddust/android/AndroidBackend.java new file mode 100644 index 0000000..c1650ad --- /dev/null +++ b/android/src/ch/asynk/rustanddust/android/AndroidBackend.java @@ -0,0 +1,15 @@ +package ch.asynk.rustanddust.android; + +import android.app.Application; + +import ch.asynk.rustanddust.Backend; + +public class AndroidBackend implements Backend +{ + private Application app; + + public AndroidBackend(Application app) + { + this.app = app; + } +} diff --git a/android/src/ch/asynk/rustanddust/android/AndroidLauncher.java b/android/src/ch/asynk/rustanddust/android/AndroidLauncher.java index 46f2da9..a60693e 100644 --- a/android/src/ch/asynk/rustanddust/android/AndroidLauncher.java +++ b/android/src/ch/asynk/rustanddust/android/AndroidLauncher.java @@ -4,13 +4,16 @@ import android.os.Bundle; import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; + import ch.asynk.rustanddust.RustAndDust; +import ch.asynk.rustanddust.Backend; -public class AndroidLauncher extends AndroidApplication { - @Override - protected void onCreate (Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); - initialize(new RustAndDust(), config); - } +public class AndroidLauncher extends AndroidApplication +{ + @Override + protected void onCreate (Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); + initialize(new RustAndDust(new AndroidBackend(this.getApplication())), config); + } } diff --git a/core/src/ch/asynk/rustanddust/Backend.java b/core/src/ch/asynk/rustanddust/Backend.java new file mode 100644 index 0000000..357304f --- /dev/null +++ b/core/src/ch/asynk/rustanddust/Backend.java @@ -0,0 +1,5 @@ +package ch.asynk.rustanddust; + +public interface Backend +{ +} diff --git a/core/src/ch/asynk/rustanddust/RustAndDust.java b/core/src/ch/asynk/rustanddust/RustAndDust.java index 9334123..146b982 100644 --- a/core/src/ch/asynk/rustanddust/RustAndDust.java +++ b/core/src/ch/asynk/rustanddust/RustAndDust.java @@ -61,6 +61,7 @@ public class RustAndDust extends Game public Ctrl ctrl; public Config config; public int hudCorrection; + public Backend backend; public TextureAtlas uiAtlas; public BitmapFont font; @@ -74,6 +75,11 @@ public class RustAndDust extends Game } private State state; + public RustAndDust(Backend backend) + { + this.backend = backend; + } + public static void debug(String msg) { Gdx.app.debug(DOM, msg); diff --git a/desktop/src/ch/asynk/rustanddust/desktop/DesktopBackend.java b/desktop/src/ch/asynk/rustanddust/desktop/DesktopBackend.java new file mode 100644 index 0000000..4b54056 --- /dev/null +++ b/desktop/src/ch/asynk/rustanddust/desktop/DesktopBackend.java @@ -0,0 +1,10 @@ +package ch.asynk.rustanddust.desktop; + +import ch.asynk.rustanddust.Backend; + +public class DesktopBackend implements Backend +{ + public DesktopBackend() + { + } +} diff --git a/desktop/src/ch/asynk/rustanddust/desktop/DesktopLauncher.java b/desktop/src/ch/asynk/rustanddust/desktop/DesktopLauncher.java index 439e4f1..c1ab457 100644 --- a/desktop/src/ch/asynk/rustanddust/desktop/DesktopLauncher.java +++ b/desktop/src/ch/asynk/rustanddust/desktop/DesktopLauncher.java @@ -13,6 +13,6 @@ public class DesktopLauncher { config.height = 768; // config.fullscreen = true; config.addIcon("data/icon.png", Files.FileType.Internal); - new LwjglApplication(new RustAndDust(), config); + new LwjglApplication(new RustAndDust(new DesktopBackend()), config); } } -- cgit v1.1-2-g2b99