Restructured the project for a release

Moved to javaecs, compiled via maven
Added changes to readme
This commit is contained in:
Brychan Dempsey 2021-06-07 18:00:39 +12:00
parent 8ffe1db4af
commit d66c23fcb3
18 changed files with 76 additions and 25 deletions

21
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Launch App",
"request": "launch",
"mainClass": "nz.ac.massey.programming_project_159333_s1_2021.App",
"projectName": "javaecs"
}
]
}

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}

View File

@ -1 +1,4 @@
# JavaECS # JavaECS
An implementation of an Entity-Component-System in Java. Based on the C++ implementation by [Austin Morlan](https://code.austinmorlan.com/austin/ecs).
See the [documentation](https://git.software.kauripeak.co.nz/BrychanD/JavaECS-Docs/wiki) for implmentation details

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>nz.ac.massey.programming_project_159333_s1_2021</groupId> <groupId>nz.ac.massey.programming_project_159333_s1_2021</groupId>
<artifactId>javaecs</artifactId> <artifactId>javaecs</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.1-SNAPSHOT</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
@ -38,6 +38,28 @@
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId> <artifactId>maven-enforcer-plugin</artifactId>
@ -58,7 +80,7 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <!-- <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version> <version>${maven-checkstyle-plugin.version}</version>
@ -88,7 +110,7 @@
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin> -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
@ -112,7 +134,7 @@
<goal>report</goal> <goal>report</goal>
</goals> </goals>
</execution> </execution>
<execution> <!-- <execution>
<id>check-unit-test</id> <id>check-unit-test</id>
<phase>test</phase> <phase>test</phase>
<goals> <goals>
@ -158,7 +180,7 @@
</rule> </rule>
</rules> </rules>
</configuration> </configuration>
</execution> </execution> -->
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
import java.util.BitSet; import java.util.BitSet;
@ -65,25 +65,27 @@ public final class App {
boolean quit = false; boolean quit = false;
long loopStart = System.currentTimeMillis(); long loopStart = System.currentTimeMillis();
long startTime = System.nanoTime();
// One potential way to do this
while (!quit){ while (!quit){
// Get the time between frames for accurate time-based calculations (i.e. physics systems etc) // Get the time between frames for accurate time-based calculations (i.e. physics systems etc)
long startTime = System.nanoTime();
frameRateSystem.update(dt, idleTime); frameRateSystem.update(dt, idleTime);
physicsSystem.update(dt); physicsSystem.update(dt);
logVec2DSystem.update(dt); logVec2DSystem.update(dt);
dt = (System.nanoTime() - startTime) / 1e9; // convert nanoseconds to seconds dt = (System.nanoTime() - startTime) / 1e9; // convert nanoseconds to seconds
startTime = System.nanoTime();
// Limit frame rate (approximately) to minimum of 16 ms // Limit frame rate (approximately) to minimum of 16 ms
if (dt < frameRate){ if (dt < frameRate){
idleTime = frameRate-dt; idleTime = frameRate-dt;
Thread.sleep((int)((frameRate-dt)*1000)); Thread.sleep((int)((frameRate-dt)*1000));
dt = (System.nanoTime() - startTime) / 1e9; dt = (System.nanoTime() - startTime) / 1e9;
startTime = System.nanoTime();
} }
if (System.currentTimeMillis() - loopStart >= 1000){ if (System.currentTimeMillis() - loopStart >= 1000){
loopStart = System.currentTimeMillis(); loopStart = System.currentTimeMillis();
System.out.println("Second Elapsed"); System.out.println("Second Elapsed");
} }
} }
} }
} }

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
/** /**
* Component Array * Component Array
* Defines the data structure that component data is stored under. * Defines the data structure that component data is stored under.

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
/** /**
* Component Manager * Component Manager
* This class manages component registrations, and adding, * This class manages component registrations, and adding,

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
/** /**
* ECS manager class. * ECS manager class.
* Call this class and its functions to interact correctly with the ECS system. * Call this class and its functions to interact correctly with the ECS system.

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
/** /**
* ECS System class * ECS System class
* This class stores entity-system registrations. These are * This class stores entity-system registrations. These are

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
/** /**
* Entity Manager * Entity Manager
* This class manages entity allocations; keeping a list * This class manages entity allocations; keeping a list

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
public class FrameRateSystem extends ECSSystem{ public class FrameRateSystem extends ECSSystem{
void init() {} void init() {}

View File

@ -1,9 +1,9 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
public class Gravity { public class Gravity {
public Gravity(){ public Gravity(){
} }
public Gravity(double x, double y){ public Gravity(double x, double y){
this.x = x; this.x = x;
this.y = y; this.y = y;
@ -15,7 +15,7 @@ public class Gravity {
this.terminalY = terminalY; this.terminalY = terminalY;
} }
double x = 0.0; double x = 0.0;
double y = -9.80665; double y = -9.80665; // Force of gravity (from https://www.bipm.org/en/publications/si-brochure - 9th edition - p159 - Bureau International des Poids et Mesures - CC BY 4.0)
// Gravity won't be considered if the velocity exceeds this (absolute value). Negative values are ignored (not limited) // Gravity won't be considered if the velocity exceeds this (absolute value). Negative values are ignored (not limited)
double terminalX = -1.0; double terminalX = -1.0;
double terminalY = -1.0; double terminalY = -1.0;

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
public class LogVec2DSystem extends ECSSystem{ public class LogVec2DSystem extends ECSSystem{
ECS gameEngine; ECS gameEngine;

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
public class PhysicsSystem extends ECSSystem{ public class PhysicsSystem extends ECSSystem{
ECS gameEngine; ECS gameEngine;

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
public class RidgidBody { public class RidgidBody {
public RidgidBody(){} public RidgidBody(){}

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
/** /**
* System Manager * System Manager
* This class manages systems registrations, and keeps a current list * This class manages systems registrations, and keeps a current list

View File

@ -1,4 +1,4 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
public class Vec2D { public class Vec2D {
public Vec2D(){} public Vec2D(){}

View File

@ -1,7 +1,8 @@
package nz.ac.massey.programming_project_159333_s1_2021; package nz.ac.massey.javaecs;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
@ -9,7 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.BitSet; import java.util.BitSet;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
/** /**