all compiles and "works" now.
This commit is contained in:
@@ -4,49 +4,30 @@ package mightypork.rogue.screens.test_bouncyboxes;
|
||||
import java.util.Random;
|
||||
|
||||
import mightypork.gamecore.control.timing.Updateable;
|
||||
import mightypork.gamecore.gui.components.painters.AbstractPainter;
|
||||
import mightypork.gamecore.gui.components.SimplePainter;
|
||||
import mightypork.gamecore.render.Render;
|
||||
import mightypork.utils.math.animation.AnimDouble;
|
||||
import mightypork.utils.math.animation.Easing;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.constraints.RectBound;
|
||||
import mightypork.utils.math.constraints.num.NumBound;
|
||||
import mightypork.utils.math.constraints.num.Num;
|
||||
import mightypork.utils.math.constraints.rect.Rect;
|
||||
|
||||
|
||||
public class BouncyBox extends AbstractPainter implements Updateable {
|
||||
public class BouncyBox extends SimplePainter implements Updateable {
|
||||
|
||||
private final Random rand = new Random();
|
||||
|
||||
private final RectBound box;
|
||||
private final Rect box;
|
||||
|
||||
private final AnimDouble pos = new AnimDouble(0, Easing.BOUNCE_OUT);
|
||||
|
||||
|
||||
public BouncyBox() {
|
||||
// create box
|
||||
final NumBound side = height(this);
|
||||
RectBound abox = box(this, side, side);
|
||||
Rect abox;
|
||||
|
||||
// move
|
||||
final NumBound move_length = sub(width(this), side);
|
||||
final NumBound offset = mul(move_length, pos);
|
||||
abox = move(abox, offset, 0);
|
||||
|
||||
// add padding
|
||||
/*
|
||||
* leftEdge(this)
|
||||
* .growRight(height(this))
|
||||
* .move(
|
||||
* width(this)
|
||||
* .sub(height(this))
|
||||
* .mul(pos),
|
||||
* 0)
|
||||
* .shrink(
|
||||
* height(this)
|
||||
* .perc(10)
|
||||
* )
|
||||
*/
|
||||
abox = shrink(abox, perc(side, 10));
|
||||
abox = leftEdge().growRight(height());
|
||||
abox = abox.move(width().sub(height()).mul(pos), Num.ZERO);
|
||||
abox = abox.shrink(height().perc(10));
|
||||
|
||||
box = abox;
|
||||
}
|
||||
@@ -55,7 +36,7 @@ public class BouncyBox extends AbstractPainter implements Updateable {
|
||||
@Override
|
||||
public void render()
|
||||
{
|
||||
Render.quad(box.getRect(), RGB.GREEN);
|
||||
Render.quad(box, RGB.GREEN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ import mightypork.gamecore.input.Keys;
|
||||
import mightypork.gamecore.render.fonts.FontRenderer.Align;
|
||||
import mightypork.rogue.Res;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.constraints.RectBound;
|
||||
import mightypork.utils.math.constraints.vect.VectConst;
|
||||
import mightypork.utils.math.constraints.rect.Rect;
|
||||
import mightypork.utils.math.constraints.vect.Vect;
|
||||
|
||||
|
||||
public class LayerBouncyBoxes extends ScreenLayer {
|
||||
@@ -45,11 +45,14 @@ public class LayerBouncyBoxes extends ScreenLayer {
|
||||
});
|
||||
|
||||
// shrink screen rect by 8% on all sides
|
||||
final RectBound holder_rect = shrink(this, perc(width(this), 4));
|
||||
|
||||
addChildClient(layout = new RowHolder(screen, holder_rect, 11));
|
||||
final Rect b = bounds();
|
||||
|
||||
for (int i = 0; i <= 9; i++) {
|
||||
final Rect holder_rect = b.shrink(b.height().perc(8));
|
||||
|
||||
addChildClient(layout = new RowHolder(screen, holder_rect, 2));
|
||||
|
||||
for (int i = 0; i <= 0; i++) {
|
||||
final BouncyBox bbr = new BouncyBox();
|
||||
layout.add(bbr);
|
||||
boxes.add(bbr);
|
||||
@@ -57,7 +60,7 @@ public class LayerBouncyBoxes extends ScreenLayer {
|
||||
|
||||
final TextPainter tp = new TextPainter(Res.getFont("default"), Align.LEFT, RGB.WHITE);
|
||||
tp.setText("Press \"C\" for \"Cat\" screen.");
|
||||
tp.setShadow(RGB.RED, VectConst.make(2, 2));
|
||||
tp.setShadow(RGB.RED, Vect.make(2, 2));
|
||||
|
||||
layout.add(tp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user