Change project structure & added GameManager

This commit is contained in:
Sebastian Cabrera 2019-08-28 23:07:02 -04:00
parent fd22091920
commit ece217c7f6
15 changed files with 52 additions and 21 deletions

4
.vscode/launch.json vendored
View file

@ -12,9 +12,9 @@
},
{
"type": "java",
"name": "Debug (Launch)-Init<pixels>",
"name": "Debug (Launch)-GameManager<pixels>",
"request": "launch",
"mainClass": "bz.bronze.pixels.Init",
"mainClass": "bz.bronze.pixels.game.GameManager",
"projectName": "pixels"
}
]

Binary file not shown.

View file

@ -1,4 +1,4 @@
package bz.bronze.pixels;
package bz.bronze.pixels.engine;
public abstract class AbstractGame {
public abstract void update(float dt);

View file

@ -1,23 +1,23 @@
package bz.bronze.pixels;
package bz.bronze.pixels.engine;
import java.awt.event.KeyEvent;
public class Gameloop implements Runnable {
public class GameContainer implements Runnable {
private Thread thread;
private Window window;
private Renderer renderer;
private Input input;
public Input input;
private AbstractGame game;
private boolean running = false;
private final double TPS = 1.0/60.0;
private final double TPS = 1.0 / 60.0;
private String metrics;
public Gameloop(AbstractGame game) {
public GameContainer(AbstractGame game) {
this.game = game;
}
public void start() {
window = new Window();
renderer = new Renderer();
input = new Input();

View file

@ -1,9 +1,8 @@
package bz.bronze.pixels;
package bz.bronze.pixels.engine;
public class Init {
static Window window = new Window();
static Gameloop game = new Gameloop();
//static Gameloop game = new Gameloop();
public static void print(String out) {
System.out.println(out);
@ -11,13 +10,13 @@ public class Init {
public static void init() {
window.create();
game.start();
//game.start();
print("Window Initialized!");
print("Gameloop Started!");
}
public static void main(String[] args) throws Exception {
init();
}
//public static void main(String[] args) throws Exception {
//init();
//}
}

View file

@ -1,4 +1,4 @@
package bz.bronze.pixels;
package bz.bronze.pixels.engine;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

View file

@ -1,4 +1,4 @@
package bz.bronze.pixels;
package bz.bronze.pixels.engine;
import java.awt.image.DataBufferInt;

View file

@ -1,4 +1,4 @@
package bz.bronze.pixels;
package bz.bronze.pixels.engine;
import java.awt.BorderLayout;
import java.awt.Canvas;

View file

@ -0,0 +1,32 @@
package bz.bronze.pixels.game;
import java.awt.event.KeyEvent;
import bz.bronze.pixels.engine.AbstractGame;
import bz.bronze.pixels.engine.GameContainer;
import bz.bronze.pixels.engine.Renderer;
public class GameManager extends AbstractGame {
static GameContainer gc;
public GameManager() {
}
@Override
public void update(float dt) {
if (gc.input.isKey(KeyEvent.VK_SPACE)) {
System.out.println("pop goes the weasel");
}
}
@Override
public void render(Renderer r) {
}
public static void main(String[] args) {
gc = new GameContainer(new GameManager());
gc.start();
}
}