aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/Subconscious.java
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-02-10 14:41:49 +0100
committerNao Pross <naopross@thearcway.org>2018-02-10 14:41:49 +0100
commitd677dbead66c2c52c2ffc51a64ece0a06114d2ad (patch)
tree188a7a6fc693dd47de18648577fba3c247361f2c /src/main/java/Subconscious.java
parentImplement barebone game engine (diff)
downloadSubconscious-old-d677dbead66c2c52c2ffc51a64ece0a06114d2ad.tar.gz
Subconscious-old-d677dbead66c2c52c2ffc51a64ece0a06114d2ad.zip
Switch to gradle, update gitignore
Diffstat (limited to 'src/main/java/Subconscious.java')
-rw-r--r--src/main/java/Subconscious.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/main/java/Subconscious.java b/src/main/java/Subconscious.java
new file mode 100644
index 0000000..b63eb23
--- /dev/null
+++ b/src/main/java/Subconscious.java
@@ -0,0 +1,79 @@
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Dimension;
+
+
+public class Subconscious extends JPanel {
+
+ public static final String TITLE = "Subconscious";
+
+ /* graphics */
+ public JFrame window;
+ // public Graphics dbGraphics; // double buffered graphics
+ // public Image dbImage = null; // double buffered image
+
+ public Scene currentScene;
+
+ /* game */
+ public boolean gameOver = false;
+ public boolean running = false;
+
+ public Subconscious() {
+ createWindow();
+
+ // TODO remove demo
+ currentScene = new WorldScene(new Dimension(200, 200), 50);
+ }
+
+ public void createWindow() {
+ window = new JFrame(TITLE);
+ window.setSize(new Dimension(800, 600));
+ window.setLocationRelativeTo(null);
+ window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ window.add(this);
+ }
+
+ /* game logic */
+ public void gameLoop() {
+
+ }
+
+ public void gameRender() {
+
+ }
+
+ public void start() {
+ running = true;
+ gameOver = false;
+
+ window.setVisible(true);
+
+ while (running) {
+ gameLoop();
+ gameRender();
+ repaint();
+
+ try {
+ // TODO replace with correct timing
+ Thread.sleep(20);
+ } catch (InterruptedException ex) {
+ //
+ }
+ }
+ }
+
+ /* graphics */
+ @Override
+ public void paintComponent(Graphics g) {
+ currentScene.render(g);
+ }
+
+ /* main */
+ public static void main(String args[]) {
+ Subconscious game = new Subconscious();
+ game.start();
+ }
+}