Updated examples to the latest version

For release, used in the report/presentation
This commit is contained in:
2021-06-15 18:13:49 +12:00
parent 3c45ca9de8
commit 05c57efc52
14 changed files with 95 additions and 268 deletions
+1 -1
View File
@@ -38,7 +38,7 @@
<dependency>
<groupId>nz.ac.massey.javaecs</groupId>
<artifactId>javaecs</artifactId>
<version>0.9.2-PRERELEASE</version>
<version>1.0.1</version>
</dependency>
</dependencies>
<build>
@@ -15,8 +15,9 @@ public final class App {
/**
* Says hello to the world.
* @param args The arguments of the program.
* @throws InterruptedException
*/
public static void main(String[] args) {
public static void main(String[] args) throws InterruptedException {
int nEntities = 1_000_000;
double startTime = System.nanoTime();
Engine engine = new Engine(nEntities);
@@ -41,15 +42,16 @@ public final class App {
Entity entity = engine.createEntity();
engine.addComponent(entity, PositionComponent.class, new PositionComponent());
engine.addComponent(entity, DirectionComponent.class, new DirectionComponent());
if (i % 2 != 0){
engine.addComponent(entity, ComflabulationComponent.class, new ComflabulationComponent());
}
}
endTime = System.nanoTime();
System.out.println("Entity creation Time taken: " + (endTime - startTime) / 1e6+ " ms " + "("+ (endTime - startTime) / 1e9 + " seconds )");
// Delay as object creation is multithreaded in at least OpenJDK 1.8 - lets use see the single core performance
Thread.sleep(5000);
double dt = 1.0f/60.0f;
startTime = System.nanoTime();
movementSystem.update(dt);
@@ -23,9 +23,6 @@ public class ComflabSystem extends ECSSystem {
}
@Override
public void update() {
}
public void update(double dt) {
for (Entity entity : entities) {
ComflabulationComponent comflab = (ComflabulationComponent)ecs.getComponentData(entity, ComflabulationComponent.class);
@@ -1,6 +1,5 @@
package nz.ac.massey.javaecs.examples.Systems;
import java.lang.management.ThreadInfo;
import java.util.BitSet;
import nz.ac.massey.javaecs.ECSSystem;
@@ -26,9 +25,6 @@ public class MovementSystem extends ECSSystem {
}
@Override
public void update() {
}
public void update(double dt) {
for (Entity entity : entities) {
PositionComponent position = (PositionComponent)ecs.getComponentData(entity, PositionComponent.class);