aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/Subconscious.java
blob: 8ce6b15488be18be18feacfa901fcf18d386e53b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import javax.swing.JFrame;
import javax.swing.JPanel;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Dimension;

import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;


public class Subconscious extends JPanel implements MouseListener {

    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);
		addMouseListener(this);
    }

    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);
    }

	/* listener */
	public void mouseClicked(MouseEvent e) {
		int x = e.getX();
		int y = e.getY();
	}
	public void mousePressed(MouseEvent e) {}
	public void mouseReleased(MouseEvent e) {}
	public void mouseEntered(MouseEvent e) {}
	public void mouseExited(MouseEvent e) {}

    /* main */
    public static void main(String args[]) {
        Subconscious game = new Subconscious();
        game.start();
    }
}