Split up project into multiple modules.
This commit is contained in:
parent
c7b2513dfe
commit
8033024b13
|
@ -1,3 +1,7 @@
|
|||
.idea/
|
||||
target/
|
||||
*.iml
|
||||
|
||||
target/
|
||||
client/target/
|
||||
core/target/
|
||||
server/target/
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>starship-arena</artifactId>
|
||||
<groupId>nl.andrewl</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>nl.andrewl.starship-arena</groupId>
|
||||
<artifactId>client</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>nl.andrewl.starship-arena</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,13 +1,13 @@
|
|||
package nl.andrewl.starship_arena;
|
||||
package nl.andrewl.starship_arena.client;
|
||||
|
||||
import nl.andrewl.starship_arena.model.Arena;
|
||||
import nl.andrewl.starship_arena.model.Ship;
|
||||
import nl.andrewl.starship_arena.view.ArenaWindow;
|
||||
import nl.andrewl.starship_arena.client.model.Arena;
|
||||
import nl.andrewl.starship_arena.client.model.Ship;
|
||||
import nl.andrewl.starship_arena.client.view.ArenaWindow;
|
||||
|
||||
/**
|
||||
* The main executable class which starts the program.
|
||||
*/
|
||||
public class StarshipArena {
|
||||
public class StarshipArenaClient {
|
||||
public static void main(String[] args) {
|
||||
Ship s1 = new Ship("/ships/corvette.json");
|
||||
s1.setVelocity(0, -0.5f);
|
|
@ -1,7 +1,7 @@
|
|||
package nl.andrewl.starship_arena.control;
|
||||
package nl.andrewl.starship_arena.client.control;
|
||||
|
||||
import nl.andrewl.starship_arena.model.Camera;
|
||||
import nl.andrewl.starship_arena.model.PhysicsObject;
|
||||
import nl.andrewl.starship_arena.client.model.Camera;
|
||||
import nl.andrewl.starship_arena.client.model.PhysicsObject;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
|
@ -1,7 +1,7 @@
|
|||
package nl.andrewl.starship_arena.control;
|
||||
package nl.andrewl.starship_arena.client.control;
|
||||
|
||||
import nl.andrewl.starship_arena.model.Arena;
|
||||
import nl.andrewl.starship_arena.view.ArenaPanel;
|
||||
import nl.andrewl.starship_arena.client.model.Arena;
|
||||
import nl.andrewl.starship_arena.client.view.ArenaPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.model;
|
||||
package nl.andrewl.starship_arena.client.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.model;
|
||||
package nl.andrewl.starship_arena.client.model;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.model;
|
||||
package nl.andrewl.starship_arena.client.model;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package nl.andrewl.starship_arena.model;
|
||||
package nl.andrewl.starship_arena.client.model;
|
||||
|
||||
import nl.andrewl.starship_arena.model.ship.Cockpit;
|
||||
import nl.andrewl.starship_arena.model.ship.Gun;
|
||||
import nl.andrewl.starship_arena.model.ship.Panel;
|
||||
import nl.andrewl.starship_arena.model.ship.ShipComponent;
|
||||
import nl.andrewl.starship_arena.util.ResourceUtils;
|
||||
import nl.andrewl.starship_arena.client.model.ship.Cockpit;
|
||||
import nl.andrewl.starship_arena.client.model.ship.Gun;
|
||||
import nl.andrewl.starship_arena.client.model.ship.Panel;
|
||||
import nl.andrewl.starship_arena.client.model.ship.ShipComponent;
|
||||
import nl.andrewl.starship_arena.core.util.ResourceUtils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
|
@ -1,8 +1,8 @@
|
|||
package nl.andrewl.starship_arena.model;
|
||||
package nl.andrewl.starship_arena.client.model;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import nl.andrewl.starship_arena.model.ship.*;
|
||||
import nl.andrewl.starship_arena.client.model.ship.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.model.ship;
|
||||
package nl.andrewl.starship_arena.client.model.ship;
|
||||
|
||||
/**
|
||||
* A cockpit represents the control point of the ship.
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.model.ship;
|
||||
package nl.andrewl.starship_arena.client.model.ship;
|
||||
|
||||
import com.google.gson.*;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.model.ship;
|
||||
package nl.andrewl.starship_arena.client.model.ship;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.model.ship;
|
||||
package nl.andrewl.starship_arena.client.model.ship;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.model.ship;
|
||||
package nl.andrewl.starship_arena.client.model.ship;
|
||||
|
||||
import com.google.gson.*;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.model.ship;
|
||||
package nl.andrewl.starship_arena.client.model.ship;
|
||||
|
||||
/**
|
||||
* A simple structural panel that makes up all or part of a ship's body.
|
|
@ -1,6 +1,6 @@
|
|||
package nl.andrewl.starship_arena.model.ship;
|
||||
package nl.andrewl.starship_arena.client.model.ship;
|
||||
|
||||
import nl.andrewl.starship_arena.model.Ship;
|
||||
import nl.andrewl.starship_arena.client.model.Ship;
|
||||
|
||||
/**
|
||||
* Represents the top-level component information for any part of a ship.
|
|
@ -1,9 +1,8 @@
|
|||
package nl.andrewl.starship_arena.view;
|
||||
package nl.andrewl.starship_arena.client.view;
|
||||
|
||||
import nl.andrewl.starship_arena.control.CameraController;
|
||||
import nl.andrewl.starship_arena.model.Arena;
|
||||
import nl.andrewl.starship_arena.model.Camera;
|
||||
import nl.andrewl.starship_arena.model.PhysicsObject;
|
||||
import nl.andrewl.starship_arena.client.model.Arena;
|
||||
import nl.andrewl.starship_arena.client.model.Camera;
|
||||
import nl.andrewl.starship_arena.client.model.PhysicsObject;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
|
@ -1,9 +1,9 @@
|
|||
package nl.andrewl.starship_arena.view;
|
||||
package nl.andrewl.starship_arena.client.view;
|
||||
|
||||
import nl.andrewl.starship_arena.control.CameraController;
|
||||
import nl.andrewl.starship_arena.control.GameUpdater;
|
||||
import nl.andrewl.starship_arena.model.Arena;
|
||||
import nl.andrewl.starship_arena.util.ResourceUtils;
|
||||
import nl.andrewl.starship_arena.client.control.CameraController;
|
||||
import nl.andrewl.starship_arena.client.control.GameUpdater;
|
||||
import nl.andrewl.starship_arena.client.model.Arena;
|
||||
import nl.andrewl.starship_arena.core.util.ResourceUtils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.view;
|
||||
package nl.andrewl.starship_arena.client.view;
|
||||
|
||||
import java.awt.*;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package nl.andrewl.starship_arena.view;
|
||||
package nl.andrewl.starship_arena.client.view;
|
||||
|
||||
import nl.andrewl.starship_arena.model.Ship;
|
||||
import nl.andrewl.starship_arena.model.ship.Cockpit;
|
||||
import nl.andrewl.starship_arena.model.ship.GeometricComponent;
|
||||
import nl.andrewl.starship_arena.model.ship.Gun;
|
||||
import nl.andrewl.starship_arena.client.model.Ship;
|
||||
import nl.andrewl.starship_arena.client.model.ship.Cockpit;
|
||||
import nl.andrewl.starship_arena.client.model.ship.GeometricComponent;
|
||||
import nl.andrewl.starship_arena.client.model.ship.Gun;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>starship-arena</artifactId>
|
||||
<groupId>nl.andrewl</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>nl.andrewl.starship-arena</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,83 @@
|
|||
package nl.andrewl.starship_arena.core.physics;
|
||||
|
||||
/**
|
||||
* Standard 2-dimensional floating-point vector implementation.
|
||||
*/
|
||||
public final class Vec2F {
|
||||
public float x;
|
||||
public float y;
|
||||
|
||||
public Vec2F(float x, float y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public Vec2F(float n) {
|
||||
this(n, n);
|
||||
}
|
||||
|
||||
public Vec2F() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public Vec2F(Vec2F other) {
|
||||
this(other.x, other.y);
|
||||
}
|
||||
|
||||
public float length() {
|
||||
return (float) Math.sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
public float dot(Vec2F other) {
|
||||
return x * other.x + y * other.y;
|
||||
}
|
||||
|
||||
public Vec2F add(Vec2F other) {
|
||||
x += other.x;
|
||||
y += other.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vec2F sub(Vec2F other) {
|
||||
x -= other.x;
|
||||
y -= other.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vec2F mul(float factor) {
|
||||
x *= factor;
|
||||
y *= factor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vec2F div(float factor) {
|
||||
x /= factor;
|
||||
y /= factor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vec2F normalize() {
|
||||
return div(length());
|
||||
}
|
||||
|
||||
public Vec2F toPolar() {
|
||||
float r = length();
|
||||
float theta = (float) Math.atan2(y, x);
|
||||
x = r;
|
||||
y = theta;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vec2F toCartesian() {
|
||||
float cx = (float) (x * Math.cos(y));
|
||||
float cy = (float) (x * Math.sin(y));
|
||||
x = cx;
|
||||
y = cy;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[ " + x + ", " + y + " ]";
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package nl.andrewl.starship_arena.util;
|
||||
package nl.andrewl.starship_arena.core.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
Binary file not shown.
After Width: | Height: | Size: 604 KiB |
8
pom.xml
8
pom.xml
|
@ -6,7 +6,13 @@
|
|||
|
||||
<groupId>nl.andrewl</groupId>
|
||||
<artifactId>starship-arena</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<modules>
|
||||
<module>server</module>
|
||||
<module>core</module>
|
||||
<module>client</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
|
@ -30,7 +36,7 @@
|
|||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>nl.andrewl.starship_arena.StarshipArena</mainClass>
|
||||
<mainClass>nl.andrewl.StarshipArena</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# Starship Arena Server
|
||||
|
||||
The server is a program that runs the physics of the arena, and that clients can connect to. Each server specifically has the capability to host one or more arenas simultaneously. Clients may query the server for metadata, like which arenas are available, and their current statuses.
|
||||
|
||||
## Arena Lifecycle
|
||||
|
||||
Within the context of each arena, clients may connect during the so-called "staging" phase before the battle commences. Once all clients are assembled and the arena's settings are established, the arena transitions to the "battle" phase, where players (or AI) will control their spacecraft to achieve the configured objective. Once battle is deemed to be over, the arena transitions to the "analysis" stage, where the server provides detailed analytics and statistics about the battle to players. Spectators may join at any point, as long as the arena is open.
|
||||
|
||||
### Staging
|
||||
This is the first stage that all arenas start in. It offers the following functionality:
|
||||
- Players can connect
|
||||
- Spectators can connect
|
||||
- Configure arena settings for battle
|
||||
|
||||
### Battle
|
||||
The main stage for the arena, in which the all "players" (AI or human players) control their respective spacecraft to achieve an objective. It offers the following functionality:
|
||||
- Battle physics simulation and real-time UDP data updates sent to all connected clients
|
||||
- Spectators can connect
|
||||
- Registered players can re-connect if their connection dies for some reason
|
||||
|
||||
### Analysis
|
||||
After the battle has ended (due to time constraints, objective achieved, etc.), the arena enters the final analysis stage for a set period of time before closing. During the analysis stage, the arena will provide statistics and analysis for each player. It offers the following functionality:
|
||||
- Player statistics and analysis sent to all players
|
||||
- All clients can disconnect
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>starship-arena</artifactId>
|
||||
<groupId>nl.andrewl</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>nl.andrewl.starship-arena</groupId>
|
||||
<artifactId>server</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>nl.andrewl.starship-arena</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
package nl.andrewl.starship_arena.server;
|
||||
|
||||
public class StarshipArenaServer {
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package nl.andrewl.starship_arena.server.model;
|
||||
|
||||
public class Arena {
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 17 KiB |
|
@ -1,62 +0,0 @@
|
|||
{
|
||||
"name": "Corvette",
|
||||
"components": [
|
||||
{
|
||||
"type": "panel",
|
||||
"name": "Main Fuselage",
|
||||
"mass": 5000,
|
||||
"points": [
|
||||
{"x": 0.3, "y": 0.6},
|
||||
{"x": 0.2, "y": 0.1},
|
||||
{"x": 0.1, "y": 0.5},
|
||||
{"x": 0.2, "y": 0.8},
|
||||
{"x": 0.8, "y": 0.8},
|
||||
{"x": 0.9, "y": 0.5},
|
||||
{"x": 0.8, "y": 0.1},
|
||||
{"x": 0.7, "y": 0.6}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "panel",
|
||||
"name": "Front Cargo Bay",
|
||||
"mass": 1000,
|
||||
"points": [
|
||||
{"x": 0.4, "y": 0.2},
|
||||
{"x": 0.35, "y": 0.6},
|
||||
{"x": 0.65, "y": 0.6},
|
||||
{"x": 0.6, "y": 0.2}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "cockpit",
|
||||
"mass": 800,
|
||||
"points": [
|
||||
{"x": 0.5, "y": 0.0},
|
||||
{"x": 0.4, "y": 0.2},
|
||||
{"x": 0.6, "y": 0.2}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "gun",
|
||||
"name": "Port-Side Machine Gun",
|
||||
"mass": 500,
|
||||
"location": {"x": 0.15, "y": 0.35},
|
||||
"rotation": 0,
|
||||
"minRotation": -160,
|
||||
"maxRotation": 5,
|
||||
"barrelWidth": 0.02,
|
||||
"barrelLength": 0.2
|
||||
},
|
||||
{
|
||||
"type": "gun",
|
||||
"name": "Starboard-Side Machine Gun",
|
||||
"mass": 500,
|
||||
"location": {"x": 0.85, "y": 0.35},
|
||||
"rotation": 0,
|
||||
"minRotation": -5,
|
||||
"maxRotation": 160,
|
||||
"barrelWidth": 0.02,
|
||||
"barrelLength": 0.2
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue