diff options
Diffstat (limited to 'core/src')
5 files changed, 36 insertions, 28 deletions
diff --git a/core/src/main/java/coffee/liz/abstractionengine/app/life/EntropyAudioSystem.java b/core/src/main/java/coffee/liz/abstractionengine/app/life/EntropyAudioSystem.java index 09ba762..b57db71 100644 --- a/core/src/main/java/coffee/liz/abstractionengine/app/life/EntropyAudioSystem.java +++ b/core/src/main/java/coffee/liz/abstractionengine/app/life/EntropyAudioSystem.java @@ -49,7 +49,7 @@ public class EntropyAudioSystem implements System<LifeInput> { private final Thread audioThread; private volatile boolean running = true; - public EntropyAudioSystem() { + public EntropyAudioSystem() { audioThread = new Thread(this::audioLoop, "EntropyAudio"); audioThread.setDaemon(true); } @@ -66,10 +66,10 @@ public class EntropyAudioSystem implements System<LifeInput> { return; } - if (!audioThread.isAlive()) { - audioThread.start(); - running = true; - } + if (!audioThread.isAlive()) { + audioThread.start(); + running = true; + } final LifeSystem lifeSystem = world.getSystem(LifeSystem.class); final Vec2<Integer> gridDimensions = lifeSystem.getDimensions(); diff --git a/core/src/main/java/coffee/liz/abstractionengine/app/screen/GameScreen.java b/core/src/main/java/coffee/liz/abstractionengine/app/screen/GameScreen.java index 40f0d99..f9402d1 100644 --- a/core/src/main/java/coffee/liz/abstractionengine/app/screen/GameScreen.java +++ b/core/src/main/java/coffee/liz/abstractionengine/app/screen/GameScreen.java @@ -38,7 +38,6 @@ public class GameScreen implements Screen { EntityFactory.Player.addToWorld(gameWorld, Vec2i.builder().y(20).x(10).build()); EntityFactory.Abstraction.addToWorld(gameWorld, Vec2i.builder().y(20).x(12).build()); EntityFactory.Abstraction.addToWorld(gameWorld, Vec2i.builder().y(20).x(13).build()); - EntityFactory.Abstraction.addToWorld(gameWorld, Vec2i.builder().y(20).x(14).build()); } /** diff --git a/core/src/main/java/coffee/liz/abstractionengine/app/screen/MainMenu.java b/core/src/main/java/coffee/liz/abstractionengine/app/screen/MainMenu.java index 2ffafdd..01aa4e8 100644 --- a/core/src/main/java/coffee/liz/abstractionengine/app/screen/MainMenu.java +++ b/core/src/main/java/coffee/liz/abstractionengine/app/screen/MainMenu.java @@ -74,17 +74,25 @@ public class MainMenu implements Screen { } private static Set<Vec2<Integer>> createGliderPattern() { - // TODO: create multiple to showcase audio. - final int[][] glider = {{0, 1, 0}, {0, 1, 1}, {1, 0, 1},}; - final int offsetX = 5; - final int offsetY = 40; - final Set<Vec2<Integer>> gliderPattern = new HashSet<>(); - for (int y = 0; y < 3; y++) - for (int x = 0; x < 3; x++) - if (glider[y][x] == 1) - gliderPattern.add(Vec2i.builder().y(offsetY + y).x(offsetX + x).build()); - - return gliderPattern; + final int[][] downRight = {{0, 1, 0}, {0, 1, 1}, {1, 0, 1}}; + final int[][] downLeft = {{0, 1, 0}, {1, 1, 0}, {1, 0, 1}}; + final int[][] upRight = {{1, 0, 1}, {0, 1, 1}, {0, 1, 0}}; + final int[][] upLeft = {{1, 0, 1}, {1, 1, 0}, {0, 1, 0}}; + + final Set<Vec2<Integer>> pattern = new HashSet<>(); + stamp(pattern, upRight, 2, 2); + stamp(pattern, upLeft, GRID_DIMENSIONS.getX() - 5, 2); + stamp(pattern, downRight, 2, GRID_DIMENSIONS.getY() - 5); + stamp(pattern, downLeft, GRID_DIMENSIONS.getX() - 5, GRID_DIMENSIONS.getY() - 5); + return pattern; + } + + private static void stamp(final Set<Vec2<Integer>> cells, final int[][] pattern, final int offsetX, + final int offsetY) { + for (int y = 0; y < pattern.length; y++) + for (int x = 0; x < pattern[y].length; x++) + if (pattern[y][x] == 1) + cells.add(Vec2i.builder().x(offsetX + x).y(offsetY + y).build()); } /** @@ -155,7 +163,7 @@ public class MainMenu implements Screen { */ @Override public void dispose() { - FunctionUtils.wrapCheckedException(world::close); + FunctionUtils.wrapCheckedException(world::close); stage.dispose(); } } diff --git a/core/src/main/java/coffee/liz/ecs/DAGWorld.java b/core/src/main/java/coffee/liz/ecs/DAGWorld.java index dea83ef..b5b54c2 100644 --- a/core/src/main/java/coffee/liz/ecs/DAGWorld.java +++ b/core/src/main/java/coffee/liz/ecs/DAGWorld.java @@ -154,12 +154,12 @@ public class DAGWorld<T> implements World<T> { return Collections.unmodifiableList(result); } - @Override - public void close() throws Exception { - for (final System<T> system : systemExecutionOrder) { - system.close(); - } - componentCache.clear(); - entities.clear(); - } + @Override + public void close() throws Exception { + for (final System<T> system : systemExecutionOrder) { + system.close(); + } + componentCache.clear(); + entities.clear(); + } } diff --git a/core/src/main/java/coffee/liz/ecs/model/System.java b/core/src/main/java/coffee/liz/ecs/model/System.java index cc46f39..ac99818 100644 --- a/core/src/main/java/coffee/liz/ecs/model/System.java +++ b/core/src/main/java/coffee/liz/ecs/model/System.java @@ -27,6 +27,7 @@ public interface System<T> extends AutoCloseable { */ void update(final World<T> world, final T state, final Duration dt); - @Override - default void close() {} + @Override + default void close() { + } } |
