Move Movement enum to :API
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.bartlomiejpluta.base.api.entity;
|
||||
|
||||
import com.bartlomiejpluta.base.api.geo.Vector;
|
||||
|
||||
public enum Direction {
|
||||
UP(0, -1),
|
||||
DOWN(0, 1),
|
||||
@@ -8,9 +10,11 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.bartlomiejpluta.base.api.entity;
|
||||
|
||||
import com.bartlomiejpluta.base.api.geo.Vector;
|
||||
|
||||
public interface Movement {
|
||||
boolean perform();
|
||||
|
||||
Movement another();
|
||||
|
||||
Vector getFrom();
|
||||
|
||||
Vector getTo();
|
||||
|
||||
Direction getDirection();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user