started implementing tweening system
This commit is contained in:
parent
66c05256e6
commit
91169a40b0
|
@ -26,6 +26,7 @@
|
||||||
<option name="PARENTHESES_EXPRESSION_LPAREN_WRAP" value="true" />
|
<option name="PARENTHESES_EXPRESSION_LPAREN_WRAP" value="true" />
|
||||||
<option name="PARENTHESES_EXPRESSION_RPAREN_WRAP" value="true" />
|
<option name="PARENTHESES_EXPRESSION_RPAREN_WRAP" value="true" />
|
||||||
<option name="BINARY_OPERATION_WRAP" value="5" />
|
<option name="BINARY_OPERATION_WRAP" value="5" />
|
||||||
|
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||||
<option name="WRAP_LONG_LINES" value="true" />
|
<option name="WRAP_LONG_LINES" value="true" />
|
||||||
<indentOptions>
|
<indentOptions>
|
||||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
|
|
@ -3,24 +3,32 @@ package com.danitheskunk.skunkworks;
|
||||||
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
import com.danitheskunk.skunkworks.gfx.IRenderContext;
|
||||||
import com.danitheskunk.skunkworks.gfx.font.IFont;
|
import com.danitheskunk.skunkworks.gfx.font.IFont;
|
||||||
import com.danitheskunk.skunkworks.nodes.Node;
|
import com.danitheskunk.skunkworks.nodes.Node;
|
||||||
|
import com.danitheskunk.skunkworks.nodes.NodeRoot;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public abstract class BaseGame {
|
public abstract class BaseGame {
|
||||||
protected Engine engine;
|
protected Engine engine;
|
||||||
protected IWindow window;
|
protected IWindow window;
|
||||||
protected IFont debugFont;
|
protected IFont debugFont;
|
||||||
protected Node rootNode;
|
protected NodeRoot rootNode;
|
||||||
|
|
||||||
public BaseGame(Vec2i windowSize, String windowTitle) {
|
public BaseGame(Vec2i windowSize, String windowTitle) {
|
||||||
this.engine = new Engine();
|
this.engine = new Engine();
|
||||||
this.window = engine.openWindow(windowSize, windowTitle);
|
this.window = engine.openWindow(windowSize, windowTitle);
|
||||||
//todo: load from .jar
|
//todo: load from .jar
|
||||||
this.debugFont = window.loadFontTileset("fonts/ega-8x14.png");
|
this.debugFont = window.loadFontTileset("fonts/ega-8x14.png");
|
||||||
this.rootNode = new Node();
|
this.rootNode = new NodeRoot();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
double lastTime, currentTime, delta;
|
||||||
|
|
||||||
|
lastTime = GLFW.glfwGetTime();
|
||||||
while(!window.shouldClose()) {
|
while(!window.shouldClose()) {
|
||||||
|
currentTime = GLFW.glfwGetTime();
|
||||||
|
delta = currentTime - lastTime;
|
||||||
|
lastTime = currentTime;
|
||||||
window.tick();
|
window.tick();
|
||||||
//todo: frame rate control
|
//todo: frame rate control
|
||||||
update(1000.0 / 60.0);
|
update(1000.0 / 60.0);
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.danitheskunk.skunkworks;
|
||||||
|
|
||||||
|
public enum Timestep {
|
||||||
|
FIXED, VARIABLE
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.danitheskunk.skunkworks.nodes;
|
||||||
|
|
||||||
|
public abstract class BaseTween {
|
||||||
|
protected double progress;
|
||||||
|
|
||||||
|
public BaseTween() {
|
||||||
|
progress = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProgress(double progress) {
|
||||||
|
this.progress = progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void apply();
|
||||||
|
}
|
|
@ -20,6 +20,10 @@ public class Node implements Iterable<Node> {
|
||||||
pos = Vec2f.ZERO;
|
pos = Vec2f.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Node getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
public Vec2f getPos() {
|
public Vec2f getPos() {
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
@ -52,8 +56,31 @@ public class Node implements Iterable<Node> {
|
||||||
return Vec2f.add(parent.getAbsolutePos(), pos);
|
return Vec2f.add(parent.getAbsolutePos(), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Node getRoot() {
|
||||||
|
var node = this;
|
||||||
|
while(node.parent != null) {
|
||||||
|
node = node.parent;
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Node> iterator() {
|
public Iterator<Node> iterator() {
|
||||||
return children.iterator();
|
return children.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TweenPos extends BaseTween {
|
||||||
|
private final Vec2f start;
|
||||||
|
private final Vec2f end;
|
||||||
|
|
||||||
|
public TweenPos(Vec2f start, Vec2f end) {
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void apply() {
|
||||||
|
pos = Vec2f.tween(start, end, progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.danitheskunk.skunkworks.nodes;
|
||||||
|
|
||||||
|
public class NodeRoot extends Node {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.danitheskunk.skunkworks.nodes;
|
||||||
|
|
||||||
|
import com.danitheskunk.skunkworks.Timestep;
|
||||||
|
|
||||||
|
public class Tweener {
|
||||||
|
private Timestep timestepMode;
|
||||||
|
|
||||||
|
public Tweener(Timestep timestepMode) {
|
||||||
|
this.timestepMode = timestepMode;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue