preparing for rewrite of tile and item system

This commit is contained in:
Ondřej Hruška
2014-04-19 13:13:46 +02:00
parent b30f39a762
commit 7927d9a67b
16 changed files with 256 additions and 51 deletions
+33 -1
View File
@@ -1,6 +1,5 @@
package mightypork.util.constraints.rect;
import mightypork.util.annotations.FactoryMethod;
import mightypork.util.constraints.DigestCache;
import mightypork.util.constraints.Digestable;
@@ -952,4 +951,37 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
{
return new TiledRect(this, 1, rows);
}
/**
* Check for intersection
*
* @param other other rect
* @return true if they intersect
* @see org.lwjgl.util.Rectangle
*/
public boolean intersectsWith(Rect other)
{
double tw = this.size().x();
double th = this.size().y();
double rw = other.size().x();
double rh = other.size().y();
if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
return false;
}
double tx = this.origin().x();
double ty = this.origin().y();
double rx = other.origin().x();
double ry = other.origin().y();
rw += rx;
rh += ry;
tw += tx;
th += ty;
// overflow || intersect
return ((rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry));
}
}
@@ -19,6 +19,19 @@ public class NoiseGen {
private final double density;
/**
* make a new noise generator with a random seed
*
* @param density noise density (0..1). Lower density means larger "spots".
* @param low low bound ("valley")
* @param middle middle bound ("surface")
* @param high high bound ("hill")
*/
public NoiseGen(double density, double low, double middle, double high) {
this(density, low, middle, high, Double.doubleToLongBits(Math.random()));
}
/**
* make a new noise generator
*