diff options
Diffstat (limited to 'src/Subconscious.java')
-rw-r--r-- | src/Subconscious.java | 87 |
1 files changed, 71 insertions, 16 deletions
diff --git a/src/Subconscious.java b/src/Subconscious.java index dc15964..b63eb23 100644 --- a/src/Subconscious.java +++ b/src/Subconscious.java @@ -1,24 +1,79 @@ -import javax.swing.*; -import java.awt.*; +import javax.swing.JFrame; +import javax.swing.JPanel; -public class Subconscious { +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Dimension; - public static final Dimension WINDOW_SIZE = new Dimension(400, 400); - public Subconscious() { - JFrame frame = new JFrame("Subconscious"); +public class Subconscious extends JPanel { - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.setSize(WINDOW_SIZE); - frame.setLocationRelativeTo(null); + public static final String TITLE = "Subconscious"; - MainPanel mainPanel= new MainPanel(); - frame.add(mainPanel); + /* graphics */ + public JFrame window; + // public Graphics dbGraphics; // double buffered graphics + // public Image dbImage = null; // double buffered image + + public Scene currentScene; - frame.setVisible(true); - } + /* game */ + public boolean gameOver = false; + public boolean running = false; - public static void main(String[] args) { - Subconscious subconscious = new Subconscious(); - } + 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(); + } } |