diff --git a/src/main/java/com/pixelgamelibrary/api/ApplicationListener.java b/src/main/java/com/pixelgamelibrary/api/ApplicationListener.java
new file mode 100644
index 0000000..ee91dba
--- /dev/null
+++ b/src/main/java/com/pixelgamelibrary/api/ApplicationListener.java
@@ -0,0 +1,40 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Pixel: Game library.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+package com.pixelgamelibrary.api;
+
+/**
+ *
+ * @author robertvokac
+ */
+public interface ApplicationListener {
+
+ void resize(int width, int height);
+
+ void show();
+
+ void hide();
+
+ void pause();
+
+ void resume();
+
+ void dispose();
+
+}
diff --git a/src/main/java/com/pixelgamelibrary/api/GameAdapter.java b/src/main/java/com/pixelgamelibrary/api/GameAdapter.java
new file mode 100644
index 0000000..200a530
--- /dev/null
+++ b/src/main/java/com/pixelgamelibrary/api/GameAdapter.java
@@ -0,0 +1,91 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Pixel: Game library.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+package com.pixelgamelibrary.api;
+
+/**
+ *
+ * @author robertvokac
+ */
+public class GameAdapter implements GameI {
+
+ private ScreenI screen;
+ private OnSetScreenListener setOnSetScreenListener;
+ @Override
+ public void create() {
+
+ }
+
+ @Override
+ public void setScreen(ScreenI screen) {
+ this.screen = screen;
+ System.out.println("setOnSetScreenListener=" + setOnSetScreenListener);
+ if(setOnSetScreenListener != null) {
+ setOnSetScreenListener.onSetScreen(screen);
+ }
+ System.out.println("GameAdapter:setScreen");
+ }
+
+ @Override
+ public ScreenI getScreen() {
+ return screen;
+ }
+
+ @Override
+ public void render() {
+
+ }
+
+ @Override
+ public void resize(int width, int height) {
+
+ }
+
+ @Override
+ public void show() {
+
+ }
+
+ @Override
+ public void hide() {
+
+ }
+
+ @Override
+ public void pause() {
+
+ }
+
+ @Override
+ public void resume() {
+
+ }
+
+ @Override
+ public void dispose() {
+
+ }
+
+ @Override
+ public void setOnSetScreenListener(OnSetScreenListener setScreenListener) {
+ this.setOnSetScreenListener = setScreenListener;
+ }
+
+}
diff --git a/src/main/java/com/pixelgamelibrary/api/GameI.java b/src/main/java/com/pixelgamelibrary/api/GameI.java
new file mode 100644
index 0000000..260106b
--- /dev/null
+++ b/src/main/java/com/pixelgamelibrary/api/GameI.java
@@ -0,0 +1,37 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Pixel: Game library.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+package com.pixelgamelibrary.api;
+
+/**
+ *
+ * @author robertvokac
+ */
+public interface GameI extends ApplicationListener {
+
+ void create();
+
+ void setScreen(ScreenI screen);
+
+ ScreenI getScreen();
+
+ void render();
+
+ void setOnSetScreenListener(OnSetScreenListener setScreenListener);
+}
diff --git a/src/main/java/com/pixelgamelibrary/api/GameWrapper.java b/src/main/java/com/pixelgamelibrary/api/GameWrapper.java
new file mode 100644
index 0000000..fcb2321
--- /dev/null
+++ b/src/main/java/com/pixelgamelibrary/api/GameWrapper.java
@@ -0,0 +1,90 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Pixel: Game library.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+package com.pixelgamelibrary.api;
+
+
+/**
+ *
+ * @author robertvokac
+ */
+public class GameWrapper implements GameI {
+
+ private final GameI game;
+
+ public GameWrapper(GameI gameI) {
+ this.game = gameI;
+ }
+
+ @Override
+ public void create() {
+ game.create();
+ }
+
+ @Override
+ public void setScreen(ScreenI screen) {
+ game.setScreen(screen);
+ }
+
+ @Override
+ public ScreenI getScreen() {
+ return game.getScreen();
+ }
+
+ @Override
+ public void render() {
+ game.render();
+ }
+
+ @Override
+ public void resize(int width, int height) {
+ game.resize(width, height);
+ }
+
+ @Override
+ public void show() {
+ game.show();
+ }
+
+ @Override
+ public void hide() {
+ game.hide();
+ }
+
+ @Override
+ public void pause() {
+ game.pause();
+ }
+
+ @Override
+ public void resume() {
+ game.resume();
+ }
+
+ @Override
+ public void dispose() {
+ game.dispose();
+ }
+
+ @Override
+ public void setOnSetScreenListener(OnSetScreenListener setScreenListener) {
+ game.setOnSetScreenListener(setScreenListener);
+ }
+}
diff --git a/src/main/java/com/pixelgamelibrary/api/Game.java b/src/main/java/com/pixelgamelibrary/api/OnSetScreenListener.java
similarity index 93%
rename from src/main/java/com/pixelgamelibrary/api/Game.java
rename to src/main/java/com/pixelgamelibrary/api/OnSetScreenListener.java
index fa12ab1..c18db40 100644
--- a/src/main/java/com/pixelgamelibrary/api/Game.java
+++ b/src/main/java/com/pixelgamelibrary/api/OnSetScreenListener.java
@@ -17,13 +17,14 @@
// or write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
+
package com.pixelgamelibrary.api;
/**
*
* @author robertvokac
*/
-public abstract class Game extends com.badlogic.gdx.Game {
-
+public interface OnSetScreenListener {
+ void onSetScreen(ScreenI screen);
}
diff --git a/src/main/java/com/pixelgamelibrary/api/Pixel.java b/src/main/java/com/pixelgamelibrary/api/Pixel.java
index d65e96a..389ccd6 100644
--- a/src/main/java/com/pixelgamelibrary/api/Pixel.java
+++ b/src/main/java/com/pixelgamelibrary/api/Pixel.java
@@ -24,6 +24,7 @@ import com.pixelgamelibrary.api.interfaces.AssetI;
import com.pixelgamelibrary.api.interfaces.AudioI;
import com.pixelgamelibrary.api.interfaces.GraphicsI;
import com.pixelgamelibrary.api.interfaces.InputI;
+import com.pixelgamelibrary.api.interfaces.InternalI;
import com.pixelgamelibrary.api.interfaces.NetI;
import com.pixelgamelibrary.api.interfaces.PixelBackend;
import com.pixelgamelibrary.api.interfaces.StorageI;
@@ -77,6 +78,10 @@ public class Pixel {
public static UtilsI utils() {
return get().utils();
}
+
+ public static InternalI internal() {
+ return get().internal();
+ }
////
public static void initBackend(PixelBackend pixelBackend) {
diff --git a/src/main/java/com/pixelgamelibrary/api/PixelApplication.java b/src/main/java/com/pixelgamelibrary/api/PixelApplication.java
new file mode 100644
index 0000000..2a3661b
--- /dev/null
+++ b/src/main/java/com/pixelgamelibrary/api/PixelApplication.java
@@ -0,0 +1,50 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Pixel: Game library.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+package com.pixelgamelibrary.api;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * @author robertvokac
+ */
+public abstract class PixelApplication {
+ abstract public GameI createGameViaMap(Map objects);
+
+ public GameI createGame() {
+ return createGame(new HashMap<>());
+ }
+ public GameI createGame(Object... objects) {
+ Map map = new HashMap<>();
+ int i = 0;
+ int maxI = objects.length - 1;
+ while(i maxI ? null : objects[i];
+ map.put(key, value);
+ }
+
+ return createGameViaMap(map);
+ }
+
+}
diff --git a/src/main/java/com/pixelgamelibrary/api/Platform.java b/src/main/java/com/pixelgamelibrary/api/Platform.java
index 7aec835..0d3c740 100644
--- a/src/main/java/com/pixelgamelibrary/api/Platform.java
+++ b/src/main/java/com/pixelgamelibrary/api/Platform.java
@@ -24,9 +24,10 @@ package com.pixelgamelibrary.api;
* @author robertvokac
*/
public enum Platform {
- DESKTOP, ANDROID, WEB;
+ DESKTOP, ANDROID, WEB, IOS;
public boolean isDesktop() {return this == DESKTOP;}
public boolean isAndroid() {return this == ANDROID;}
public boolean isWeb() {return this == WEB;}
+ public boolean isIOS() {return this == IOS;}
}
diff --git a/src/main/java/com/pixelgamelibrary/api/ScreenAdapter.java b/src/main/java/com/pixelgamelibrary/api/ScreenAdapter.java
new file mode 100644
index 0000000..2851ea6
--- /dev/null
+++ b/src/main/java/com/pixelgamelibrary/api/ScreenAdapter.java
@@ -0,0 +1,64 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Pixel: Game library.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+package com.pixelgamelibrary.api;
+
+/**
+ *
+ * @author robertvokac
+ */
+public class ScreenAdapter implements ScreenI{
+private GameI game = null;
+
+ @Override
+ public void resize(int width, int height) {
+
+ }
+
+ @Override
+ public void render(float delta) {
+
+ }
+
+ @Override
+ public void show() {
+
+ }
+
+ @Override
+ public void hide() {
+
+ }
+
+ @Override
+ public void pause() {
+
+ }
+
+ @Override
+ public void resume() {
+
+ }
+
+ @Override
+ public void dispose() {
+
+ }
+
+}
diff --git a/src/main/java/com/pixelgamelibrary/api/Screen.java b/src/main/java/com/pixelgamelibrary/api/ScreenI.java
similarity index 92%
rename from src/main/java/com/pixelgamelibrary/api/Screen.java
rename to src/main/java/com/pixelgamelibrary/api/ScreenI.java
index efbcf0b..2b35551 100644
--- a/src/main/java/com/pixelgamelibrary/api/Screen.java
+++ b/src/main/java/com/pixelgamelibrary/api/ScreenI.java
@@ -23,6 +23,7 @@ package com.pixelgamelibrary.api;
*
* @author robertvokac
*/
-public abstract class Screen extends com.badlogic.gdx.ScreenAdapter {
-
+public interface ScreenI extends ApplicationListener {
+
+ void render(float delta);
}
diff --git a/src/main/java/com/pixelgamelibrary/api/ScreenWrapper.java b/src/main/java/com/pixelgamelibrary/api/ScreenWrapper.java
new file mode 100644
index 0000000..05be481
--- /dev/null
+++ b/src/main/java/com/pixelgamelibrary/api/ScreenWrapper.java
@@ -0,0 +1,70 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Pixel: Game library.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+package com.pixelgamelibrary.api;
+
+
+/**
+ *
+ * @author robertvokac
+ */
+public class ScreenWrapper implements ScreenI {
+
+ private final ScreenI screen;
+
+ public ScreenWrapper(ScreenI screenIn) {
+ this.screen = screenIn;
+ }
+ @Override
+ public void render(float delta) {
+ screen.render(delta);
+ }
+
+ @Override
+ public void resize(int width, int height) {
+ screen.resize(width, height);
+ }
+
+ @Override
+ public void show() {
+ screen.show();
+ }
+
+ @Override
+ public void hide() {
+ screen.hide();
+ }
+
+ @Override
+ public void pause() {
+ screen.pause();
+ }
+
+ @Override
+ public void resume() {
+ screen.resume();
+ }
+
+ @Override
+ public void dispose() {
+ screen.dispose();
+ }
+
+}
diff --git a/src/main/java/com/pixelgamelibrary/api/WindowMode.java b/src/main/java/com/pixelgamelibrary/api/WindowMode.java
index 83c9414..d49704f 100644
--- a/src/main/java/com/pixelgamelibrary/api/WindowMode.java
+++ b/src/main/java/com/pixelgamelibrary/api/WindowMode.java
@@ -17,18 +17,14 @@
// or write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
///////////////////////////////////////////////////////////////////////////////////////////////
+
package com.pixelgamelibrary.api;
/**
*
* @author robertvokac
*/
-public class WindowMode {
+public enum WindowMode {
- private WindowMode() {
- //Not meant to be instantiated.
- }
-
- public static final String WINDOW = "WINDOW";
- public static final String FULLSCREEN = "FULLSCREEN";
+ WINDOW, FULLSCREEN;
}
diff --git a/src/main/java/com/pixelgamelibrary/api/interfaces/AppI.java b/src/main/java/com/pixelgamelibrary/api/interfaces/AppI.java
index 7c40c7f..23b5429 100644
--- a/src/main/java/com/pixelgamelibrary/api/interfaces/AppI.java
+++ b/src/main/java/com/pixelgamelibrary/api/interfaces/AppI.java
@@ -19,6 +19,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////
package com.pixelgamelibrary.api.interfaces;
+import com.pixelgamelibrary.api.GameI;
import com.pixelgamelibrary.api.Platform;
/**
@@ -45,4 +46,8 @@ public interface AppI {
String getAppName();
boolean isAppNameSet();
+ void setGame(GameI game);
+
+ GameI getGame();
+
}
diff --git a/src/main/java/com/pixelgamelibrary/api/interfaces/GraphicsI.java b/src/main/java/com/pixelgamelibrary/api/interfaces/GraphicsI.java
index 82cd96e..d082b84 100644
--- a/src/main/java/com/pixelgamelibrary/api/interfaces/GraphicsI.java
+++ b/src/main/java/com/pixelgamelibrary/api/interfaces/GraphicsI.java
@@ -19,12 +19,14 @@
///////////////////////////////////////////////////////////////////////////////////////////////
package com.pixelgamelibrary.api.interfaces;
+import com.pixelgamelibrary.api.WindowMode;
+
/**
*
* @author robertvokac
*/
public interface GraphicsI {
boolean setToOriginalDisplayMode();
- String setDisplayMode(boolean fullscreen, boolean window);
+ WindowMode setDisplayMode(boolean fullscreen, boolean window);
}
diff --git a/src/main/java/com/pixelgamelibrary/api/interfaces/InternalI.java b/src/main/java/com/pixelgamelibrary/api/interfaces/InternalI.java
new file mode 100644
index 0000000..2013ede
--- /dev/null
+++ b/src/main/java/com/pixelgamelibrary/api/interfaces/InternalI.java
@@ -0,0 +1,28 @@
+///////////////////////////////////////////////////////////////////////////////////////////////
+// Pixel: Game library.
+// Copyright (C) 2024 the original author or authors.
+//
+// This program is free software: you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation, either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// or write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+///////////////////////////////////////////////////////////////////////////////////////////////
+package com.pixelgamelibrary.api.interfaces;
+
+
+/**
+ *
+ * @author robertvokac
+ */
+public interface InternalI {
+}
diff --git a/src/main/java/com/pixelgamelibrary/api/interfaces/PixelBackend.java b/src/main/java/com/pixelgamelibrary/api/interfaces/PixelBackend.java
index cee98cc..0d197aa 100644
--- a/src/main/java/com/pixelgamelibrary/api/interfaces/PixelBackend.java
+++ b/src/main/java/com/pixelgamelibrary/api/interfaces/PixelBackend.java
@@ -25,8 +25,6 @@ package com.pixelgamelibrary.api.interfaces;
*/
public interface PixelBackend {
-
-
AppI app();
GraphicsI graphics();
AudioI audio();
@@ -35,5 +33,6 @@ public interface PixelBackend {
AssetI asset();
StorageI storage();
UtilsI utils();
+ InternalI internal();
}
diff --git a/src/test/java/com/pixelgamelibrary/api/storage/map/MapStorageTest.java b/src/test/java/com/pixelgamelibrary/api/storage/map/MapStorageTest.java
index 0173087..0b45c24 100644
--- a/src/test/java/com/pixelgamelibrary/api/storage/map/MapStorageTest.java
+++ b/src/test/java/com/pixelgamelibrary/api/storage/map/MapStorageTest.java
@@ -1,5 +1,6 @@
package com.pixelgamelibrary.api.storage.map;
+import com.pixelgamelibrary.api.GameI;
import com.pixelgamelibrary.api.Pixel;
import com.pixelgamelibrary.api.Platform;
import com.pixelgamelibrary.api.interfaces.AppI;
@@ -7,6 +8,7 @@ import com.pixelgamelibrary.api.interfaces.AssetI;
import com.pixelgamelibrary.api.interfaces.AudioI;
import com.pixelgamelibrary.api.interfaces.GraphicsI;
import com.pixelgamelibrary.api.interfaces.InputI;
+import com.pixelgamelibrary.api.interfaces.InternalI;
import com.pixelgamelibrary.api.interfaces.NetI;
import com.pixelgamelibrary.api.interfaces.PixelBackend;
import com.pixelgamelibrary.api.interfaces.StorageI;
@@ -75,6 +77,16 @@ public class MapStorageTest {
public boolean isAppNameSet() {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
+
+ @Override
+ public void setGame(GameI game) {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+
+ @Override
+ public GameI getGame() {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
};
}
@@ -113,6 +125,11 @@ public class MapStorageTest {
public UtilsI utils() {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
+
+ @Override
+ public InternalI internal() {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
};
Pixel.initBackend(dummyPixelBackend);
}