color palettes, fps in overlay, main menu screen w/ buttons

This commit is contained in:
Ondřej Hruška
2014-04-16 21:57:17 +02:00
parent 56b61e5936
commit 56494e04f9
50 changed files with 841 additions and 539 deletions
+11 -1
View File
@@ -9,6 +9,7 @@ import mightypork.util.constraints.num.caching.NumDigest;
import mightypork.util.constraints.num.mutable.NumVar;
import mightypork.util.constraints.num.proxy.NumBound;
import mightypork.util.constraints.num.proxy.NumBoundAdapter;
import mightypork.util.constraints.vect.Vect;
import mightypork.util.math.Calc;
@@ -69,7 +70,7 @@ public abstract class Num implements NumBound, Digestable<NumDigest> {
private Num p_neg;
private Num p_abs;
private DigestCache<NumDigest> dc = new DigestCache<NumDigest>() {
private final DigestCache<NumDigest> dc = new DigestCache<NumDigest>() {
@Override
protected NumDigest createDigest()
@@ -747,4 +748,13 @@ public abstract class Num implements NumBound, Digestable<NumDigest> {
{
return Calc.toString(value());
}
/**
* @return vect with both coords of this size
*/
public Vect toVectXY()
{
return Vect.make(this);
}
}
+13 -1
View File
@@ -192,7 +192,7 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
private Rect p_edge_t;
private Rect p_edge_b;
private DigestCache<RectDigest> dc = new DigestCache<RectDigest>() {
private final DigestCache<RectDigest> dc = new DigestCache<RectDigest>() {
@Override
protected RectDigest createDigest()
@@ -443,6 +443,12 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
}
public Rect shrink(Num x, Num y)
{
return shrink(x, x, y, y);
}
/**
* Shrink the rect
*
@@ -603,6 +609,12 @@ public abstract class Rect implements RectBound, Digestable<RectDigest> {
}
public Rect grow(Num x, Num y)
{
return grow(x, x, y, y);
}
/**
* Grow the rect
*
@@ -437,4 +437,15 @@ public class RectConst extends Rect {
return super.centerTo(parent).freeze();
}
public RectConst shrink(NumConst x, NumConst y)
{
return super.shrink(x, y).freeze();
}
public RectConst grow(NumConst x, NumConst y)
{
return super.grow(x, y).freeze();
}
}
@@ -4,12 +4,11 @@ package mightypork.util.constraints.rect.builders;
import mightypork.util.constraints.num.Num;
import mightypork.util.constraints.rect.Rect;
import mightypork.util.constraints.rect.proxy.RectProxy;
import mightypork.util.logging.Log;
/**
* Utility for cutting rect into evenly sized cells.<br>
* It's by default one-based, but this can be switched by calling the oneBased()
* and zeroBased() methods.
* Utility for cutting rect into evenly sized cells.
*
* @author MightyPork
*/
@@ -20,8 +19,6 @@ public class TiledRect extends RectProxy {
final private Num perRow;
final private Num perCol;
private int based = 1;
public TiledRect(Rect source, int horizontal, int vertical) {
super(source);
@@ -33,30 +30,6 @@ public class TiledRect extends RectProxy {
}
/**
* Set to one-based mode, and return itself (for chaining).
*
* @return this
*/
public TiledRect oneBased()
{
based = 1;
return this;
}
/**
* Set to zero-based mode, and return itself (for chaining).
*
* @return this
*/
public TiledRect zeroBased()
{
based = 0;
return this;
}
/**
* Get a tile.
*
@@ -67,9 +40,6 @@ public class TiledRect extends RectProxy {
*/
public Rect tile(int x, int y)
{
x -= based;
y -= based;
if (x >= tilesX || x < 0) {
throw new IndexOutOfBoundsException("X coordinate out fo range.");
}
@@ -97,22 +67,19 @@ public class TiledRect extends RectProxy {
*/
public Rect span(int x_from, int y_from, int size_x, int size_y)
{
x_from -= based;
y_from -= based;
final int x_to = x_from + size_x;
final int y_to = y_from + size_y;
final int x_to = x_from + size_x - 1;
final int y_to = y_from + size_y - 1;
if (size_x <= 0 || size_y <= 0) {
throw new IndexOutOfBoundsException("Size must be > 0.");
Log.w("Size must be > 0.", new IllegalAccessException());
}
if (x_from >= tilesX || x_from < 0 || x_to >= tilesX || x_to < 0) {
throw new IndexOutOfBoundsException("X coordinate(s) out of range.");
Log.w("X coordinate(s) out of range.", new IllegalAccessException());
}
if (y_from >= tilesY || y_from < 0 || y_to >= tilesY || y_to < 0) {
throw new IndexOutOfBoundsException("Y coordinate(s) out of range.");
Log.w("Y coordinate(s) out of range.", new IllegalAccessException());
}
final Num leftMove = left().add(perCol.mul(x_from));
@@ -131,7 +98,7 @@ public class TiledRect extends RectProxy {
*/
public Rect column(int n)
{
return tile(n, based);
return tile(n, 0);
}
@@ -144,6 +111,6 @@ public class TiledRect extends RectProxy {
*/
public Rect row(int n)
{
return tile(based, n);
return tile(0, n);
}
}
@@ -38,6 +38,7 @@ public class RectDigest {
@Override
public String toString()
{
return String.format("Rect{ at: (%.1f, %.1f), size: (%.1f, %.1f), bounds: L %.1f R %.1f T %.1f B %.1f }", x, y, width, height, left, right, top, bottom);
return String
.format("Rect{ at: (%.1f, %.1f), size: (%.1f, %.1f), bounds: L %.1f R %.1f T %.1f B %.1f }", x, y, width, height, left, right, top, bottom);
}
}
+13 -1
View File
@@ -133,7 +133,7 @@ public abstract class Vect implements VectBound, Digestable<VectDigest> {
private Num p_yc;
private Num p_zc;
private DigestCache<VectDigest> dc = new DigestCache<VectDigest>() {
private final DigestCache<VectDigest> dc = new DigestCache<VectDigest>() {
@Override
protected VectDigest createDigest()
@@ -1216,4 +1216,16 @@ public abstract class Vect implements VectBound, Digestable<VectDigest> {
{
return String.format("(%.1f, %.1f, %.1f)", x(), y(), z());
}
public final boolean isInside(Rect bounds)
{
return bounds.contains(this);
}
public Rect startRect()
{
return expand(0, 0, 0, 0);
}
}