added NodeText
This commit is contained in:
parent
2aec5c4981
commit
6f66d7391f
|
@ -7,6 +7,7 @@ import com.danitheskunk.skunkworks.audio.nodes.Node;
|
||||||
import com.danitheskunk.skunkworks.audio.nodes.SamplePlayer;
|
import com.danitheskunk.skunkworks.audio.nodes.SamplePlayer;
|
||||||
import com.danitheskunk.skunkworks.audio.nodes.TTS;
|
import com.danitheskunk.skunkworks.audio.nodes.TTS;
|
||||||
import com.danitheskunk.skunkworks.backends.gl.Gamepad;
|
import com.danitheskunk.skunkworks.backends.gl.Gamepad;
|
||||||
|
import com.danitheskunk.skunkworks.gfx.Color;
|
||||||
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
||||||
import com.danitheskunk.skunkworks.gfx.ITexture;
|
import com.danitheskunk.skunkworks.gfx.ITexture;
|
||||||
import com.danitheskunk.skunkworks.gfx.font.IFont;
|
import com.danitheskunk.skunkworks.gfx.font.IFont;
|
||||||
|
@ -161,21 +162,12 @@ public abstract class BaseGame {
|
||||||
if(currentFrameTime >= 1.0 / 60.0) {
|
if(currentFrameTime >= 1.0 / 60.0) {
|
||||||
rootNode.tick();
|
rootNode.tick();
|
||||||
update(1.0 / 60.0);
|
update(1.0 / 60.0);
|
||||||
/*
|
|
||||||
var rc3d = window.renderStart3D();
|
|
||||||
render3D(rc3d);
|
|
||||||
window.renderFinish3D(rc3d);
|
|
||||||
var rc = window.renderStart();
|
|
||||||
renderPre(rc);
|
|
||||||
rootNode.render(rc);
|
|
||||||
render(rc);
|
|
||||||
window.renderFinish(rc);
|
|
||||||
window.runScaler();
|
|
||||||
*/
|
|
||||||
var p3d = window.getPipeline3D();
|
var p3d = window.getPipeline3D();
|
||||||
var p2d = window.getPipeline2D();
|
var p2d = window.getPipeline2D();
|
||||||
window.startFrame();
|
window.startFrame();
|
||||||
p3d.startFrame();
|
p3d.startFrame();
|
||||||
|
//todo: should be transparent but bugged
|
||||||
|
p3d.getRenderContext().clear(Color.BLACK);
|
||||||
render3D(p3d.getRenderContext());
|
render3D(p3d.getRenderContext());
|
||||||
p3d.finishFrame();
|
p3d.finishFrame();
|
||||||
p2d.startFrame();
|
p2d.startFrame();
|
||||||
|
|
|
@ -1,22 +1,28 @@
|
||||||
package com.danitheskunk.skunkworks;
|
package com.danitheskunk.skunkworks;
|
||||||
|
|
||||||
import com.danitheskunk.skunkworks.audio.ISample;
|
import com.danitheskunk.skunkworks.audio.ISample;
|
||||||
|
import com.danitheskunk.skunkworks.gfx.font.FontTileset;
|
||||||
import com.danitheskunk.skunkworks.nodes.NodeSprite;
|
import com.danitheskunk.skunkworks.nodes.NodeSprite;
|
||||||
|
import com.danitheskunk.skunkworks.nodes.NodeText;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public class TestNode extends BaseGame {
|
public class TestNode extends BaseGame {
|
||||||
private final ISample kick;
|
private final ISample kick;
|
||||||
private final NodeSprite sprite;
|
private final NodeSprite sprite;
|
||||||
|
private final NodeText text;
|
||||||
float[] axes;
|
float[] axes;
|
||||||
|
|
||||||
public TestNode() {
|
public TestNode() {
|
||||||
super(new Vec2i(1280, 720), "Skunkworks");
|
super(new Vec2i(1280, 720), "Skunkworks");
|
||||||
|
|
||||||
kick = loadSample("demoassets/kick.wav");
|
kick = loadSample("demoassets/kick.wav");
|
||||||
|
var font = window.loadFontTileset("fonts/ega-8x14.png");
|
||||||
|
text = new NodeText(font, "Hello World!");
|
||||||
sprite = new NodeSprite();
|
sprite = new NodeSprite();
|
||||||
sprite.setTexture(loadTexture("demoassets/test.png"));
|
sprite.setTexture(loadTexture("demoassets/card.png"));
|
||||||
sprite.setPos(new Vec2f(100, 100));
|
sprite.setPos(new Vec2f(100, 100));
|
||||||
rootNode.add(sprite);
|
//rootNode.add(sprite);
|
||||||
|
rootNode.add(text);
|
||||||
//doThing();
|
//doThing();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +37,7 @@ public class TestNode extends BaseGame {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void update(double delta) {
|
protected void update(double delta) {
|
||||||
sprite.setPos(new Vec2f(640 + 640 * gamepad.getAxis(0), 360 + 360 * gamepad.getAxis(1)));
|
text.setPos(new Vec2f(640 + 640 * gamepad.getAxis(0), 360 + 360 * gamepad.getAxis(1)));
|
||||||
if(gamepad.getButtonPressed(0)) {
|
if(gamepad.getButtonPressed(0)) {
|
||||||
playSample(kick);
|
playSample(kick);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.danitheskunk.skunkworks.nodes;
|
||||||
|
|
||||||
|
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
||||||
|
import com.danitheskunk.skunkworks.gfx.font.IFont;
|
||||||
|
|
||||||
|
public class NodeText extends Node {
|
||||||
|
private IFont font;
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
public NodeText(IFont font, String text) {
|
||||||
|
this.font = font;
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(IRenderContext rc) {
|
||||||
|
rc.drawString(getAbsolutePos().toVec2i(), text, font);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFont(IFont font) {
|
||||||
|
this.font = font;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue