aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/los/numeros
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/los/numeros/example/Main.java20
-rw-r--r--src/main/java/los/numeros/example/modules/ExampleModule.java17
-rw-r--r--src/main/java/los/numeros/gameEngine/Engine.java41
-rw-r--r--src/main/java/los/numeros/gameEngine/Module.java13
4 files changed, 91 insertions, 0 deletions
diff --git a/src/main/java/los/numeros/example/Main.java b/src/main/java/los/numeros/example/Main.java
new file mode 100644
index 0000000..02fe35e
--- /dev/null
+++ b/src/main/java/los/numeros/example/Main.java
@@ -0,0 +1,20 @@
+package los.numeros.example;
+
+import java.util.function.BooleanSupplier;
+
+import los.numeros.example.modules.*;
+import los.numeros.gameEngine.Engine;
+import los.numeros.gameEngine.Module;
+
+public class Main implements Engine {
+ BooleanSupplier running = () -> true;
+ Module modules[];
+
+ public Main() {
+ /* put the modules in an array */
+ modules[modules.length] = new ExampleModule();
+
+ /* start the game */
+ Engine.StartEngine(running, modules);
+ }
+}
diff --git a/src/main/java/los/numeros/example/modules/ExampleModule.java b/src/main/java/los/numeros/example/modules/ExampleModule.java
new file mode 100644
index 0000000..0e2d103
--- /dev/null
+++ b/src/main/java/los/numeros/example/modules/ExampleModule.java
@@ -0,0 +1,17 @@
+package los.numeros.example.modules;
+
+import los.numeros.gameEngine.Module;
+
+public class ExampleModule implements Module {
+ @Override
+ public int init()
+ {
+ return 0;
+ }
+
+ @Override
+ public int end()
+ {
+ return 0;
+ }
+}
diff --git a/src/main/java/los/numeros/gameEngine/Engine.java b/src/main/java/los/numeros/gameEngine/Engine.java
new file mode 100644
index 0000000..ba09cf0
--- /dev/null
+++ b/src/main/java/los/numeros/gameEngine/Engine.java
@@ -0,0 +1,41 @@
+package los.numeros.gameEngine;
+
+import java.util.function.BooleanSupplier;
+
+public interface Engine {
+ public static int StartEngine(BooleanSupplier running, Module modules[])
+ {
+ /* start game init tasks */
+ GameStart();
+
+ /* run module inits */
+ for (Module module : modules) {
+ module.init();
+ }
+
+ /* wait for the game to end */
+ while (running.getAsBoolean());
+
+ /* run game end tasks */
+ GameEnd();
+
+ /* run module ends */
+ for (Module module : modules) {
+ module.end();
+ }
+
+ return 0;
+ }
+
+ public static int
+ GameStart()
+ {
+ return 0;
+ }
+
+ public static int
+ GameEnd()
+ {
+ return 0;
+ }
+}
diff --git a/src/main/java/los/numeros/gameEngine/Module.java b/src/main/java/los/numeros/gameEngine/Module.java
new file mode 100644
index 0000000..0406615
--- /dev/null
+++ b/src/main/java/los/numeros/gameEngine/Module.java
@@ -0,0 +1,13 @@
+package los.numeros.gameEngine;
+
+public interface Module {
+ /**
+ * code to run when the game is started
+ */
+ public int init();
+
+ /**
+ * code to run when the game has ended
+ */
+ public int end();
+}