Compare commits

..

No commits in common. "16fdcee0575323d1fd5b23cedd1dd2eba6777bf3" and "f52d6e66e3f06b1f02db3b9d1a4a521b7e197b6e" have entirely different histories.

4 changed files with 4 additions and 40 deletions

View File

@ -1,32 +1,18 @@
package com.danitheskunk.skunkworks; package com.danitheskunk.skunkworks;
import com.danitheskunk.skunkworks.audio.AudioEngine;
import com.danitheskunk.skunkworks.audio.ISample;
import com.danitheskunk.skunkworks.audio.nodes.Mixer;
import com.danitheskunk.skunkworks.audio.nodes.Node;
import com.danitheskunk.skunkworks.audio.nodes.SamplePlayer;
import com.danitheskunk.skunkworks.gfx.IRenderContext; import com.danitheskunk.skunkworks.gfx.IRenderContext;
import com.danitheskunk.skunkworks.gfx.ITexture;
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.NodeRoot; import com.danitheskunk.skunkworks.nodes.NodeRoot;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
public abstract class BaseGame { public abstract class BaseGame {
protected Engine engine; protected Engine engine;
protected AudioEngine audioEngine;
protected Mixer mixer;
protected SamplePlayer samplePlayer;
protected IWindow window; protected IWindow window;
protected IFont debugFont; protected IFont debugFont;
protected NodeRoot rootNode; protected NodeRoot rootNode;
public BaseGame(Vec2i windowSize, String windowTitle) { public BaseGame(Vec2i windowSize, String windowTitle) {
this.audioEngine = new AudioEngine(44100, 256, 8);
this.mixer = new Mixer(this.audioEngine, 2);
this.samplePlayer = new SamplePlayer(this.audioEngine);
Node.connect(samplePlayer, 0, mixer, 0);
this.audioEngine.setNode(this.mixer);
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
@ -52,7 +38,6 @@ public abstract class BaseGame {
rootNode.render(rc); rootNode.render(rc);
render(rc); render(rc);
window.renderFinish(rc); window.renderFinish(rc);
audioEngine.refill();
} }
} }
@ -73,20 +58,4 @@ public abstract class BaseGame {
protected void update(double delta) { protected void update(double delta) {
} }
protected ISample loadSample(String path) {
return audioEngine.loadSample(path);
}
protected void playSample(ISample sample) {
samplePlayer.play(sample);
}
protected void playSample(ISample sample, boolean looping) {
samplePlayer.play(sample, looping);
}
protected ITexture loadTexture(String path) {
return window.loadTexture(path);
}
} }

View File

@ -1,24 +1,19 @@
package com.danitheskunk.skunkworks; package com.danitheskunk.skunkworks;
import com.danitheskunk.skunkworks.audio.ISample;
import com.danitheskunk.skunkworks.nodes.NodeSprite; import com.danitheskunk.skunkworks.nodes.NodeSprite;
public class TestNode extends BaseGame { public class TestNode extends BaseGame {
NodeSprite sprite; NodeSprite sprite;
ISample kick;
public TestNode() { public TestNode() {
super(new Vec2i(1280, 720), "Skunkworks"); super(new Vec2i(1280, 720), "Skunkworks");
kick = loadSample("demoassets/kick.wav");
sprite = new NodeSprite(); sprite = new NodeSprite();
sprite.setTexture(loadTexture("demoassets/test.png")); sprite.setTexture(window.loadTexture("demoassets/test.png"));
sprite.setPos(new Vec2f(100, 100)); sprite.setPos(new Vec2f(100, 100));
rootNode.add(sprite); rootNode.add(sprite);
sprite.tweenPos(new Vec2f(800, 400), 120).delay(60).then(() -> { sprite.tweenPos(new Vec2f(800, 400), 120).delay(60).then(() -> {
System.out.println("yay! got there! now lets go home"); System.out.println("yay! got there! now lets go home");
sprite.tweenPos(new Vec2f(100, 100), 120); sprite.tweenPos(new Vec2f(100, 100), 120);
playSample(kick);
}); });
} }

View File

@ -27,7 +27,7 @@ public class TestSound {
var sin3 = new Sine(engine, 523.25); var sin3 = new Sine(engine, 523.25);
engine.setNode(mix); engine.setNode(mix);
//Node.connect(sin1, 0, mix, 0); //Node.connect(sin1, 0, mix, 0);
Node.connect(sin3, 0, mix, 1); //Node.connect(sin3, 0, mix, 1);
//Node.connect(sin2, 0, mix, 2); //Node.connect(sin2, 0, mix, 2);
var loop = engine.loadSample("C:\\Users\\dani\\Downloads\\AKWF" + var loop = engine.loadSample("C:\\Users\\dani\\Downloads\\AKWF" +
@ -41,7 +41,7 @@ public class TestSound {
player.play(loop, true); player.play(loop, true);
for(int j = 0; j < 10; ++j) { for(int j = 0; j < 10; ++j) {
player.play(kick); //player.play(kick);
for(int i = 0; i < 50; ++i) { for(int i = 0; i < 50; ++i) {
engine.refill(); engine.refill();
Thread.sleep(20); Thread.sleep(20);

Binary file not shown.