laatste versie

This commit is contained in:
unknown
2015-04-08 15:56:46 +02:00
parent c2cb07cf3e
commit 69c05da3fd
18 changed files with 726 additions and 215 deletions
+33
View File
@@ -1,6 +1,9 @@
package Objects;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import Applicatie.Panel;
public class Entrance extends DrawObject
{
@@ -15,5 +18,35 @@ public class Entrance extends DrawObject
{
return "Entrance";
}
public void setPosition(Point2D position, boolean b)
{
//this.position = position;
Rectangle2D rect = getRectangle();
double xl = (Panel.getFieldWidth()/2) + rect.getMinX();
double xr = Panel.getFieldWidth() - (Panel.getFieldWidth()/2 + rect.getMaxX());
double yt = (Panel.getFieldHeight()/2) + rect.getMinY();
double yb = Panel.getFieldHeight() - (Panel.getFieldHeight()/2 + rect.getMaxY());
if(xl < xr && xl < yt && xl < yb)
{
this.position = new Point2D.Double(-Panel.getFieldWidth()/2, position.getY());
}
else if(xr < xl && xr < yt && xr < yb)
{
this.position = new Point2D.Double(Panel.getFieldWidth()/2 - rect.getWidth(), position.getY());
}
else if(yt < xl && yt < xr && yt < yb)
{
this.position = new Point2D.Double(position.getX(), -Panel.getFieldHeight()/2);
}
else if(yb < xl && yb < yt && yb < xr)
{
this.position = new Point2D.Double(position.getX(), Panel.getFieldHeight()/2 - rect.getHeight());
}
else
{
this.position = new Point2D.Double(-Panel.getFieldWidth()/2, -Panel.getFieldHeight()/2);
}
}
}