preparing for rewrite of tile and item system
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user