I've been using Shapes and what I'm missing is Point class like Vector2f but that will satisfy Shape stuff
so Point(x,y) that extends Shape, without it you can't have uniform way of handling collision detection with shapes and I find myself writing many logic exceptions in code because of it. For example you can use new Polygon(new float[] {x, y}) but that really hurts when doing Shape.intersects() or Shape.contains() as you cannot optimize it (or you can with a huge exception...)
I've written a small implementation that I plan to use:
Why don't we have Point already? Am I missing something?
Code:
import org.newdawn.slick.geom.Shape;
import org.newdawn.slick.geom.Transform;
public class Point extends Shape
{
public Point(float x, float y)
{
this.x = x;
this.y = y;
checkPoints();
}
@Override
public Shape transform(Transform transform)
{
float result[] = new float[points.length];
transform.transform(points, 0, result, 0, points.length / 2);
return new Point(points[0], points[1]);
}
@Override
protected void createPoints()
{
points = new float[2];
points[0] = getX();
points[1] = getY();
maxX = x;
maxY = y;
minX = x;
minY = y;
findCenter();
calculateRadius();
}
@Override
protected void findCenter()
{
center[0] = points[0];
center[1] = points[1];
}
@Override
protected void calculateRadius()
{
boundingCircleRadius = 0;
}
}