tweaked gradient rendering

This commit is contained in:
Ondřej Hruška
2014-04-10 09:39:11 +02:00
parent 861d007b27
commit dacb43df3a
19 changed files with 190 additions and 113 deletions
+67 -67
View File
@@ -56,21 +56,62 @@ public class App extends BaseApp {
}
/**
* Handle a crash
*
* @param error
*/
public static void onCrash(Throwable error)
@Override
protected void initScreens(ScreenRegistry screens)
{
if (Log.ready()) {
Log.e("The game has crashed!", error);
} else {
System.err.println("The game has crashed!");
error.printStackTrace();
}
screens.add(new ScreenTestBouncy(this));
screens.add(new ScreenTestCat(this));
screens.add(new ScreenTestFont(this));
screens.add(new ScreenTestRender(this));
if (inst != null) inst.shutdown();
screens.showScreen("test.render");
}
@Override
protected void initBus(EventBus bus)
{
super.initBus(bus);
// custom channels
bus.addChannel(ActionRequest.class, ActionRequest.Listener.class);
//bus.detailedLogging = true;
}
@Override
protected void initInputSystem(InputSystem input)
{
// Go fullscreen
getInput().bindKeyStroke(new KeyStroke(Keys.KEY_F11), new Runnable() {
@Override
public void run()
{
getEventBus().send(new ActionRequest(RequestType.FULLSCREEN));
}
});
// Take screenshot
getInput().bindKeyStroke(new KeyStroke(Keys.KEY_F2), new Runnable() {
@Override
public void run()
{
getEventBus().send(new ActionRequest(RequestType.SCREENSHOT));
}
});
// Exit
getInput().bindKeyStroke(new KeyStroke(Keys.KEY_LCONTROL, Keys.KEY_Q), new Runnable() {
@Override
public void run()
{
getEventBus().send(new ActionRequest(RequestType.SHUTDOWN));
}
});
}
@@ -110,41 +151,6 @@ public class App extends BaseApp {
}
@Override
protected void initInputSystem(InputSystem input)
{
// Go fullscreen
getInput().bindKeyStroke(new KeyStroke(Keys.KEY_F11), new Runnable() {
@Override
public void run()
{
getEventBus().send(new ActionRequest(RequestType.FULLSCREEN));
}
});
// Take screenshot
getInput().bindKeyStroke(new KeyStroke(Keys.KEY_F2), new Runnable() {
@Override
public void run()
{
getEventBus().send(new ActionRequest(RequestType.SCREENSHOT));
}
});
// Exit
getInput().bindKeyStroke(new KeyStroke(Keys.KEY_LCONTROL, Keys.KEY_Q), new Runnable() {
@Override
public void run()
{
getEventBus().send(new ActionRequest(RequestType.SHUTDOWN));
}
});
}
@Override
protected GameLoop createLoop()
{
@@ -159,18 +165,6 @@ public class App extends BaseApp {
}
@Override
protected void initScreens(ScreenRegistry screens)
{
screens.add(new ScreenTestBouncy(this));
screens.add(new ScreenTestCat(this));
screens.add(new ScreenTestFont(this));
screens.add(new ScreenTestRender(this));
screens.showScreen("test.cat");
}
@Override
protected File getLockFile()
{
@@ -178,15 +172,21 @@ public class App extends BaseApp {
}
@Override
protected void initBus(EventBus bus)
/**
* Handle a crash
*
* @param error
*/
public static void onCrash(Throwable error)
{
super.initBus(bus);
if (Log.ready()) {
Log.e("The game has crashed!", error);
} else {
System.err.println("The game has crashed!");
error.printStackTrace();
}
// custom channels
bus.addChannel(ActionRequest.class, ActionRequest.Listener.class);
bus.detailedLogging = true;
if (inst != null) inst.shutdown();
}
}
@@ -5,7 +5,7 @@ import static mightypork.gamecore.gui.constraints.Constraints.*;
import java.util.Random;
import mightypork.gamecore.control.interf.Updateable;
import mightypork.gamecore.control.timing.Updateable;
import mightypork.gamecore.gui.components.PluggableRenderer;
import mightypork.gamecore.gui.constraints.NumberConstraint;
import mightypork.gamecore.gui.constraints.RectConstraint;
@@ -6,7 +6,7 @@ import static mightypork.gamecore.gui.constraints.Constraints.*;
import java.util.Random;
import mightypork.gamecore.control.bus.events.MouseButtonEvent;
import mightypork.gamecore.control.interf.Updateable;
import mightypork.gamecore.control.timing.Updateable;
import mightypork.gamecore.gui.components.painters.ImagePainter;
import mightypork.gamecore.gui.components.painters.TextPainter;
import mightypork.gamecore.gui.constraints.RectConstraint;
@@ -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 = _grow(_center(this), 0, _div(_height(this), 10));
final RectConstraint strbox = _centered(_box(_div(_screenH, 10)), this);
tp.setContext(strbox);
}
@@ -2,7 +2,7 @@ package mightypork.rogue.screens.test_render;
import static mightypork.gamecore.gui.constraints.Constraints.*;
import mightypork.gamecore.gui.constraints.Poller;
import mightypork.gamecore.control.timing.Poller;
import mightypork.gamecore.gui.constraints.RectConstraint;
import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer;
@@ -17,24 +17,22 @@ public class LayerTestGradient extends ScreenLayer {
private final RectConstraint pos1;
private final RectConstraint pos2;
private final RectConstraint pos3;
public LayerTestGradient(Screen screen) {
super(screen);
pos1 = _cache(p, _grow_down(_top_edge(this), 64));
pos2 = _cache(p, _shrink_up(_grow_right(_left_edge(this), 64), 64));
pos3 = _cache(p, _move(_grow(_center(this), 70, 10), 100, 100));
pos2 = _cache(p, _shrink_top(_grow_right(_left_edge(this), 64), 64));
}
@Override
public void render()
{
Render.quadColor(getRect(), RGB.WHITE, RGB.BLUE, RGB.BLACK, RGB.PURPLE);
Render.quadGradH(pos1.getRect(), RGB.GREEN, RGB.RED);
Render.quadGradV(pos2.getRect(), RGB.WHITE, RGB.PURPLE);
Render.quad(pos3.getRect(), RGB.RED);
}