misc changes (abstract game)
This commit is contained in:
parent
ffd9ed775c
commit
fd22091920
8 changed files with 18 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
|||
# pixels
|
||||
|
||||
x, y - 2D Game engine in the works...
|
||||
x, y - 2D Game engine in the works...
|
||||
|
||||
idk why i use java for everything...
|
BIN
pixels/bin/bz/bronze/pixels/AbstractGame.class
Normal file
BIN
pixels/bin/bz/bronze/pixels/AbstractGame.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6
pixels/src/bz/bronze/pixels/AbstractGame.java
Normal file
6
pixels/src/bz/bronze/pixels/AbstractGame.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package bz.bronze.pixels;
|
||||
|
||||
public abstract class AbstractGame {
|
||||
public abstract void update(float dt);
|
||||
public abstract void render(Renderer r);
|
||||
}
|
|
@ -6,12 +6,17 @@ public class Gameloop implements Runnable {
|
|||
private Thread thread;
|
||||
private Renderer renderer;
|
||||
private Input input;
|
||||
private AbstractGame game;
|
||||
|
||||
private boolean running = false;
|
||||
private final double TPS = 1.0/60.0;
|
||||
|
||||
private String metrics;
|
||||
|
||||
public Gameloop(AbstractGame game) {
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
renderer = new Renderer();
|
||||
input = new Input();
|
||||
|
@ -53,6 +58,8 @@ public class Gameloop implements Runnable {
|
|||
render = true;
|
||||
|
||||
//TODO: Gameloop
|
||||
game.update((float)TPS);
|
||||
|
||||
metrics = "TPS: " + tps + " | " + "Mouse X: " + input.mouseX + " | " + "Mouse Y: " + input.mouseY + " | " + "Scroll: " + input.scroll;
|
||||
Window.window.setTitle(Window.title + " | " + metrics);
|
||||
|
||||
|
@ -68,6 +75,7 @@ public class Gameloop implements Runnable {
|
|||
if (render) {
|
||||
renderer.test();
|
||||
//renderer.clear();
|
||||
game.render(renderer);
|
||||
|
||||
Window.update();
|
||||
ticks++;
|
||||
|
|
|
@ -15,7 +15,7 @@ public class Window {
|
|||
static int width = 800;
|
||||
static int height = 600;
|
||||
static int scale = 1;
|
||||
static String title = "pixels | v0.02";
|
||||
static String title = "pixels | v0.03";
|
||||
|
||||
static BufferedImage pixels = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
static Canvas viewport = new Canvas();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue