diff options
Diffstat (limited to 'src/main/java/los/numeros/GameEngine')
-rw-r--r-- | src/main/java/los/numeros/GameEngine/Engine.java | 24 | ||||
-rw-r--r-- | src/main/java/los/numeros/GameEngine/Module.java | 13 |
2 files changed, 37 insertions, 0 deletions
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..2cc509a --- /dev/null +++ b/src/main/java/los/numeros/GameEngine/Engine.java @@ -0,0 +1,24 @@ +package los.numeros.GameEngine; + +import java.util.function.BooleanSupplier; + +public interface Engine { + public static int + StartEngine(BooleanSupplier running, Module modules[]) + { + /* run module inits */ + for (Module module : modules) { + module.init(); + } + + /* wait for the game to end */ + while (running.getAsBoolean()); + + /* run module ends */ + for (Module module : modules) { + module.end(); + } + + 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..53b8e5e --- /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(); +} |