Fixed exceptions due to the renderer not being ready

This commit is contained in:
Brychan Dempsey 2021-06-12 15:56:13 +12:00
parent 117589b17b
commit 3c45ca9de8
2 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package nz.ac.massey.javaecs.examples;
import java.util.Random;
import java.util.concurrent.Semaphore;
import javafx.scene.paint.Color;
import nz.ac.massey.javaecs.*;
@ -14,6 +15,8 @@ public final class App {
private App() {
}
public static Semaphore rendererReadySemaphore = new Semaphore(0);
/**
* Simple physics simulation.
* @param args The arguments of the program.
@ -127,10 +130,11 @@ public final class App {
/************************************
** Run init() on the systems **
*************************************/
renderSystem.init();
rendererReadySemaphore.acquire();
physicsSystem.init();
collisionSystem.init();
logUpdateSystem.init();
renderSystem.init();
existenceSystem.init();
reportSystem.init();

View File

@ -14,6 +14,7 @@ import javafx.stage.Stage;
import nz.ac.massey.javaecs.ECSSystem;
import nz.ac.massey.javaecs.Engine;
import nz.ac.massey.javaecs.Entity;
import nz.ac.massey.javaecs.examples.App;
import nz.ac.massey.javaecs.examples.Components.BoxRender;
import nz.ac.massey.javaecs.examples.Components.Render;
import nz.ac.massey.javaecs.examples.Components.TextRender;
@ -102,6 +103,8 @@ public class RenderSystem extends ECSSystem{
Scene scene = new Scene(root, 1024, 1024, Color.BLACK);
primaryStage.setScene(scene);
primaryStage.show();
// Signal the renderer is ready
App.rendererReadySemaphore.release();
}
public static void run(){