Finished Coord system, but some bugs in rects.
This commit is contained in:
@@ -29,6 +29,25 @@ import mightypork.utils.logging.LogWriter;
|
||||
*/
|
||||
public class App extends BaseApp {
|
||||
|
||||
@Override
|
||||
protected LogWriter createLog()
|
||||
{
|
||||
Locale.setDefault(Locale.ENGLISH);
|
||||
|
||||
final LogWriter log = Log.create("runtime", Paths.LOG_FILE, 5);
|
||||
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initDisplay(DisplaySystem display)
|
||||
{
|
||||
display.createMainWindow(Const.WINDOW_W, Const.WINDOW_H, true, Config.START_IN_FS, Const.TITLEBAR);
|
||||
display.setTargetFps(Const.FPS_RENDER);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initScreens(ScreenRegistry screens)
|
||||
{
|
||||
@@ -41,6 +60,27 @@ public class App extends BaseApp {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected GameLoop createLoop()
|
||||
{
|
||||
return new MainLoop(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initResources()
|
||||
{
|
||||
Res.load(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected File getLockFile()
|
||||
{
|
||||
return Paths.LOCK;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initBus(EventBus bus)
|
||||
{
|
||||
@@ -84,44 +124,4 @@ public class App extends BaseApp {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected LogWriter createLog()
|
||||
{
|
||||
Locale.setDefault(Locale.ENGLISH);
|
||||
|
||||
final LogWriter log = Log.create("runtime", Paths.LOG_FILE, 10);
|
||||
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initDisplay(DisplaySystem display)
|
||||
{
|
||||
display.createMainWindow(Const.WINDOW_W, Const.WINDOW_H, true, Config.START_IN_FS, Const.TITLEBAR);
|
||||
display.setTargetFps(Const.FPS_RENDER);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected GameLoop createLoop()
|
||||
{
|
||||
return new MainLoop(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initResources()
|
||||
{
|
||||
Res.load(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected File getLockFile()
|
||||
{
|
||||
return Paths.LOCK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package mightypork.rogue.screens;
|
||||
|
||||
|
||||
import static mightypork.gamecore.gui.constraints.Constraints.*;
|
||||
import static mightypork.utils.math.constraints.Constraints.*;
|
||||
import mightypork.gamecore.gui.components.painters.TextPainter;
|
||||
import mightypork.gamecore.gui.constraints.RectConstraint;
|
||||
import mightypork.gamecore.gui.screens.Screen;
|
||||
import mightypork.gamecore.gui.screens.ScreenLayer;
|
||||
import mightypork.gamecore.render.fonts.FontRenderer.Align;
|
||||
import mightypork.gamecore.render.fonts.GLFont;
|
||||
import mightypork.rogue.Res;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.coord.Vec;
|
||||
import mightypork.utils.string.StringProvider;
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ public class LayerFps extends ScreenLayer {
|
||||
|
||||
final GLFont font = Res.getFont("default");
|
||||
|
||||
final RectConstraint constraint = _round(_move(_grow_down(_right_top(this), 32), -8, 8));
|
||||
final RectConstraint constraint = _box(_sub(_top_right(this), 8, 8), 0, 32);
|
||||
|
||||
tp = new TextPainter(font, Align.RIGHT, RGB.WHITE, text);
|
||||
tp.setContext(constraint);
|
||||
|
||||
tp.setShadow(RGB.BLACK, Coord.at(1, 1));
|
||||
tp.setShadow(RGB.BLACK, Vec.ONE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package mightypork.rogue.screens.test_bouncyboxes;
|
||||
|
||||
|
||||
import static mightypork.gamecore.gui.constraints.Constraints.*;
|
||||
import static mightypork.utils.math.constraints.Constraints.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mightypork.gamecore.control.timing.Updateable;
|
||||
import mightypork.gamecore.gui.components.PluggableRenderer;
|
||||
import mightypork.gamecore.gui.constraints.NumberConstraint;
|
||||
import mightypork.gamecore.gui.constraints.RectConstraint;
|
||||
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.NumberConstraint;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
|
||||
|
||||
public class BouncyBox extends PluggableRenderer implements Updateable {
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package mightypork.rogue.screens.test_bouncyboxes;
|
||||
|
||||
|
||||
import static mightypork.gamecore.gui.constraints.Constraints.*;
|
||||
import static mightypork.utils.math.constraints.Constraints.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mightypork.gamecore.gui.components.layout.RowHolder;
|
||||
import mightypork.gamecore.gui.components.painters.TextPainter;
|
||||
import mightypork.gamecore.gui.constraints.RectConstraint;
|
||||
import mightypork.gamecore.gui.screens.Screen;
|
||||
import mightypork.gamecore.gui.screens.ScreenLayer;
|
||||
import mightypork.gamecore.input.KeyStroke;
|
||||
@@ -16,6 +15,7 @@ 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.RectConstraint;
|
||||
import mightypork.utils.string.StringProvider;
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package mightypork.rogue.screens.test_cat_sound;
|
||||
|
||||
|
||||
import static mightypork.gamecore.gui.constraints.Constraints.*;
|
||||
import static mightypork.utils.math.constraints.Constraints.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -19,14 +19,15 @@ import mightypork.rogue.Res;
|
||||
import mightypork.utils.math.animation.AnimDouble;
|
||||
import mightypork.utils.math.animation.Easing;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.math.coord.AnimCoord;
|
||||
import mightypork.utils.math.coord.CoordValue;
|
||||
import mightypork.utils.math.coord.Vec;
|
||||
|
||||
|
||||
public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButtonEvent.Listener {
|
||||
|
||||
private final AnimDouble size = new AnimDouble(400, Easing.SINE_BOTH);
|
||||
private final AnimDouble xPos = new AnimDouble(200, Easing.ELASTIC_OUT);
|
||||
private final AnimDouble yPos = new AnimDouble(200, Easing.ELASTIC_OUT);
|
||||
private final AnimCoord pos = new AnimCoord(Vec.ZERO, Easing.ELASTIC_OUT);
|
||||
|
||||
private final Random rand = new Random();
|
||||
|
||||
@@ -37,18 +38,18 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
|
||||
public LayerFlyingCat(Screen screen) {
|
||||
super(screen);
|
||||
|
||||
xPos.setTo(DisplaySystem.getWidth() / 2);
|
||||
yPos.setTo(DisplaySystem.getHeight() / 2);
|
||||
pos.setTo(getDisplay().getCenter());
|
||||
|
||||
cat = new ImagePainter(Res.getTxQuad("test.kitten"));
|
||||
cat.setContext(_centered(_box(size, size), xPos, yPos));
|
||||
|
||||
cat.setContext(_align(_box(size, size), pos));
|
||||
|
||||
tp = new TextPainter(Res.getFont("default"));
|
||||
tp.setAlign(Align.CENTER);
|
||||
tp.setColor(RGB.YELLOW);
|
||||
tp.setText("Meow!");
|
||||
tp.setShadow(RGB.dark(0.8), Coord.at(2, 2));
|
||||
tp.setContext(_centered(_box(64, 64), _mouseX, _mouseY));
|
||||
tp.setShadow(RGB.dark(0.8), new CoordValue(2, 2));
|
||||
tp.setContext(_align(_box(64, 64), _mouseX, _mouseY));
|
||||
|
||||
/*
|
||||
* Register keys
|
||||
@@ -58,8 +59,7 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
xPos.fadeTo(DisplaySystem.getWidth() / 2, 2);
|
||||
yPos.fadeTo(DisplaySystem.getHeight() / 2, 2);
|
||||
pos.animateWithSpeed(getDisplay().getCenter(), 300);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -69,8 +69,7 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
|
||||
public void update(double delta)
|
||||
{
|
||||
size.update(delta);
|
||||
xPos.update(delta);
|
||||
yPos.update(delta);
|
||||
pos.update(delta);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,12 +78,13 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
|
||||
{
|
||||
if (!event.isDown()) return;
|
||||
|
||||
final Coord pos = event.getPos();
|
||||
final double t = 2;
|
||||
size.fadeTo(100 + rand.nextInt(700), t / 2D);
|
||||
final Vec pos = event.getPos();
|
||||
|
||||
xPos.fadeTo(pos.x(), t);
|
||||
yPos.fadeTo(pos.y(), t);
|
||||
final double time = 100;
|
||||
|
||||
size.animate(100 + rand.nextInt(700), time/2D);
|
||||
|
||||
this.pos.animateWithSpeed(pos, 300);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,8 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
|
||||
{
|
||||
cat.render();
|
||||
tp.render();
|
||||
|
||||
//System.out.println(tp.getRect());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package mightypork.rogue.screens.test_font;
|
||||
|
||||
|
||||
import static mightypork.gamecore.gui.constraints.Constraints.*;
|
||||
import static mightypork.utils.math.constraints.Constraints.*;
|
||||
import mightypork.gamecore.control.AppAccess;
|
||||
import mightypork.gamecore.gui.components.painters.TextPainter;
|
||||
import mightypork.gamecore.gui.constraints.RectConstraint;
|
||||
import mightypork.gamecore.gui.screens.Screen;
|
||||
import mightypork.gamecore.render.fonts.FontRenderer.Align;
|
||||
import mightypork.rogue.Res;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
|
||||
|
||||
public class ScreenTestFont extends Screen {
|
||||
@@ -22,7 +22,7 @@ public class ScreenTestFont extends Screen {
|
||||
tp = new TextPainter(Res.getFont("default"), Align.CENTER, RGB.GREEN);
|
||||
tp.setText("Hello World!");
|
||||
|
||||
final RectConstraint strbox = _centered(_box(_div(_screenH, 10)), this);
|
||||
final RectConstraint strbox = _align(_box(_div(_screenH, 10)), this);
|
||||
|
||||
tp.setContext(strbox);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package mightypork.rogue.screens.test_render;
|
||||
|
||||
|
||||
import static mightypork.gamecore.gui.constraints.Constraints.*;
|
||||
import static mightypork.utils.math.constraints.Constraints.*;
|
||||
import mightypork.gamecore.control.timing.Poller;
|
||||
import mightypork.gamecore.gui.constraints.RectConstraint;
|
||||
import mightypork.gamecore.gui.screens.Screen;
|
||||
import mightypork.gamecore.gui.screens.ScreenLayer;
|
||||
import mightypork.gamecore.render.Render;
|
||||
import mightypork.utils.math.color.RGB;
|
||||
import mightypork.utils.math.coord.Coord;
|
||||
import mightypork.utils.math.constraints.RectConstraint;
|
||||
import mightypork.utils.math.coord.Vec;
|
||||
|
||||
|
||||
public class LayerTestGradient extends ScreenLayer {
|
||||
@@ -44,7 +44,7 @@ public class LayerTestGradient extends ScreenLayer {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(Coord size)
|
||||
protected void onSizeChanged(Vec size)
|
||||
{
|
||||
p.poll();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user