Change project structure & added GameManager
This commit is contained in:
parent
fd22091920
commit
ece217c7f6
15 changed files with 52 additions and 21 deletions
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
|
@ -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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
pixels/bin/bz/bronze/pixels/game/GameManager.class
Normal file
BIN
pixels/bin/bz/bronze/pixels/game/GameManager.class
Normal file
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
package bz.bronze.pixels;
|
||||
package bz.bronze.pixels.engine;
|
||||
|
||||
public abstract class AbstractGame {
|
||||
public abstract void update(float dt);
|
|
@ -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();
|
||||
|
|
@ -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();
|
||||
//}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package bz.bronze.pixels;
|
||||
package bz.bronze.pixels.engine;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
|
@ -1,4 +1,4 @@
|
|||
package bz.bronze.pixels;
|
||||
package bz.bronze.pixels.engine;
|
||||
|
||||
import java.awt.image.DataBufferInt;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package bz.bronze.pixels;
|
||||
package bz.bronze.pixels.engine;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Canvas;
|
32
pixels/src/bz/bronze/pixels/game/GameManager.java
Normal file
32
pixels/src/bz/bronze/pixels/game/GameManager.java
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue