From ddfa2b7d9ee1547090e568e843e327cacd27fc22 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sat, 31 Jan 2026 16:04:08 -0800 Subject: Run formatter and implement todo to stamp multiple gliders into the world --- .../app/life/EntropyAudioSystem.java | 10 +++---- .../abstractionengine/app/screen/GameScreen.java | 1 - .../liz/abstractionengine/app/screen/MainMenu.java | 32 ++++++++++++++-------- core/src/main/java/coffee/liz/ecs/DAGWorld.java | 16 +++++------ .../src/main/java/coffee/liz/ecs/model/System.java | 5 ++-- 5 files changed, 36 insertions(+), 28 deletions(-) (limited to 'core') 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 { 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 { return; } - if (!audioThread.isAlive()) { - audioThread.start(); - running = true; - } + if (!audioThread.isAlive()) { + audioThread.start(); + running = true; + } final LifeSystem lifeSystem = world.getSystem(LifeSystem.class); final Vec2 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> 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> 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> 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> 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 implements World { return Collections.unmodifiableList(result); } - @Override - public void close() throws Exception { - for (final System system : systemExecutionOrder) { - system.close(); - } - componentCache.clear(); - entities.clear(); - } + @Override + public void close() throws Exception { + for (final System 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 extends AutoCloseable { */ void update(final World world, final T state, final Duration dt); - @Override - default void close() {} + @Override + default void close() { + } } -- cgit v1.2.3-70-g09d2