Replace custom Vector with JOML's Vector2* in :API
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package com.bartlomiejpluta.base.api.entity;
|
||||
|
||||
import com.bartlomiejpluta.base.api.geo.Vector;
|
||||
import org.joml.Vector2i;
|
||||
|
||||
public enum Direction {
|
||||
UP(0, -1),
|
||||
@@ -10,11 +10,13 @@ public enum Direction {
|
||||
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final Vector vector;
|
||||
|
||||
Direction(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.vector = Vector.of(x, y);
|
||||
}
|
||||
|
||||
public Vector2i asVector() {
|
||||
return new Vector2i(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
package com.bartlomiejpluta.base.api.entity;
|
||||
|
||||
import com.bartlomiejpluta.base.api.geo.Vector;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector2i;
|
||||
|
||||
public interface Entity {
|
||||
Vector getCoordinates();
|
||||
Vector2i getCoordinates();
|
||||
|
||||
void setCoordinates(Vector coordinates);
|
||||
void setCoordinates(Vector2i coordinates);
|
||||
|
||||
void setCoordinates(int x, int y);
|
||||
|
||||
Vector2f getPosition();
|
||||
|
||||
void setPosition(Vector2f position);
|
||||
|
||||
void setPosition(float x, float y);
|
||||
|
||||
Movement prepareMovement(Direction direction);
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.bartlomiejpluta.base.api.entity;
|
||||
|
||||
import com.bartlomiejpluta.base.api.geo.Vector;
|
||||
|
||||
import org.joml.Vector2i;
|
||||
|
||||
public interface Movement {
|
||||
boolean perform();
|
||||
|
||||
Movement another();
|
||||
|
||||
Vector getFrom();
|
||||
Vector2i getFrom();
|
||||
|
||||
Vector getTo();
|
||||
Vector2i getTo();
|
||||
|
||||
Direction getDirection();
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.bartlomiejpluta.base.api.geo;
|
||||
|
||||
public class Vector {
|
||||
public final int x;
|
||||
public final int y;
|
||||
|
||||
public Vector(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public Vector add(Vector other) {
|
||||
return new Vector(x + other.x, y + other.y);
|
||||
}
|
||||
|
||||
public static Vector of(int x, int y) {
|
||||
return new Vector(x, y);
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,14 @@ import com.bartlomiejpluta.base.api.entity.Movement;
|
||||
|
||||
public interface GameMap {
|
||||
void addEntity(int objectLayerIndex, Entity entity);
|
||||
|
||||
void removeEntity(int objectLayerIndex, Entity entity);
|
||||
|
||||
boolean isMovementPossible(int objectLayerIndex, Movement movement);
|
||||
|
||||
void setTile(int tileLayerIndex, int row, int column, int tileId);
|
||||
|
||||
void setTile(int tileLayerIndex, int row, int column, int tileSetRow, int tileSetColumn);
|
||||
|
||||
void clearTile(int tileLayerIndex, int row, int column);
|
||||
|
||||
void setPassageAbility(int objectLayerIndex, int row, int column, PassageAbility passageAbility);
|
||||
|
||||
void setTile(int tileLayerIndex, int row, int column, int tileId);
|
||||
void setTile(int tileLayerIndex, int row, int column, int tileSetRow, int tileSetColumn);
|
||||
void clearTile(int tileLayerIndex, int row, int column);
|
||||
|
||||
void setColor(int colorLayerIndex, float r, float g, float b, float alpha);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user