From d677dbead66c2c52c2ffc51a64ece0a06114d2ad Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sat, 10 Feb 2018 14:41:49 +0100 Subject: Switch to gradle, update gitignore --- src/Actor.java | 3 -- src/Map.java | 28 --------------- src/Scene.java | 5 --- src/Subconscious.java | 79 ----------------------------------------- src/Tile.java | 15 -------- src/WorldScene.java | 32 ----------------- src/main/java/Actor.java | 3 ++ src/main/java/Map.java | 28 +++++++++++++++ src/main/java/Scene.java | 5 +++ src/main/java/Subconscious.java | 79 +++++++++++++++++++++++++++++++++++++++++ src/main/java/Tile.java | 15 ++++++++ src/main/java/WorldScene.java | 32 +++++++++++++++++ 12 files changed, 162 insertions(+), 162 deletions(-) delete mode 100644 src/Actor.java delete mode 100644 src/Map.java delete mode 100644 src/Scene.java delete mode 100644 src/Subconscious.java delete mode 100644 src/Tile.java delete mode 100644 src/WorldScene.java create mode 100644 src/main/java/Actor.java create mode 100644 src/main/java/Map.java create mode 100644 src/main/java/Scene.java create mode 100644 src/main/java/Subconscious.java create mode 100644 src/main/java/Tile.java create mode 100644 src/main/java/WorldScene.java (limited to 'src') diff --git a/src/Actor.java b/src/Actor.java deleted file mode 100644 index 207d6e6..0000000 --- a/src/Actor.java +++ /dev/null @@ -1,3 +0,0 @@ -public class Actor { - -} diff --git a/src/Map.java b/src/Map.java deleted file mode 100644 index 031e922..0000000 --- a/src/Map.java +++ /dev/null @@ -1,28 +0,0 @@ -import java.awt.Dimension; - -public class Map { - - public final Dimension size; - public final Tile grid[]; - - // TODO load map from file - // public Map(File filename) { - public Map(Dimension size) { - this.size = size; - - // populate grid - this.grid = new Tile[this.size.width * this.size.height]; - for (int y = 0; y < this.size.width; y++) { - for (int x = 0; x < this.size.height; x++) { - this.grid[y * this.size.width + x] = new Tile(Tile.Type.GRASS, x, y); - } - } - } - - // public void load() {} - - /* accessors */ - public Tile getTile(int x, int y) { - return this.grid[y * this.size.width + y]; - } -} diff --git a/src/Scene.java b/src/Scene.java deleted file mode 100644 index a2949fd..0000000 --- a/src/Scene.java +++ /dev/null @@ -1,5 +0,0 @@ -import java.awt.Graphics; - -public abstract class Scene { - abstract void render(Graphics g); -} diff --git a/src/Subconscious.java b/src/Subconscious.java deleted file mode 100644 index b63eb23..0000000 --- a/src/Subconscious.java +++ /dev/null @@ -1,79 +0,0 @@ -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(); - } -} diff --git a/src/Tile.java b/src/Tile.java deleted file mode 100644 index cbdeda4..0000000 --- a/src/Tile.java +++ /dev/null @@ -1,15 +0,0 @@ -public class Tile { - - public enum Type { - GRASS, - }; - - public final int x, y; - public final Type type; - - public Tile(Type type, int x, int y) { - this.type = type; - this.x = x; - this.y = y; - } -} diff --git a/src/WorldScene.java b/src/WorldScene.java deleted file mode 100644 index 6dff04a..0000000 --- a/src/WorldScene.java +++ /dev/null @@ -1,32 +0,0 @@ -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; - - -public class WorldScene extends Scene { - - private Actor actors[]; - private Map map; - - private int tileSize; - - public WorldScene(Dimension gridSize, int tileSize) { - this.tileSize = tileSize; - map = new Map(gridSize); - } - - @Override - public void render(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - - for (Tile tile : this.map.grid) { - g2d.setColor(Color.GREEN); - g2d.fillRect( - this.tileSize * tile.x, - this.tileSize * tile.y, - this.tileSize, this.tileSize - ); - } - } -} diff --git a/src/main/java/Actor.java b/src/main/java/Actor.java new file mode 100644 index 0000000..207d6e6 --- /dev/null +++ b/src/main/java/Actor.java @@ -0,0 +1,3 @@ +public class Actor { + +} diff --git a/src/main/java/Map.java b/src/main/java/Map.java new file mode 100644 index 0000000..031e922 --- /dev/null +++ b/src/main/java/Map.java @@ -0,0 +1,28 @@ +import java.awt.Dimension; + +public class Map { + + public final Dimension size; + public final Tile grid[]; + + // TODO load map from file + // public Map(File filename) { + public Map(Dimension size) { + this.size = size; + + // populate grid + this.grid = new Tile[this.size.width * this.size.height]; + for (int y = 0; y < this.size.width; y++) { + for (int x = 0; x < this.size.height; x++) { + this.grid[y * this.size.width + x] = new Tile(Tile.Type.GRASS, x, y); + } + } + } + + // public void load() {} + + /* accessors */ + public Tile getTile(int x, int y) { + return this.grid[y * this.size.width + y]; + } +} diff --git a/src/main/java/Scene.java b/src/main/java/Scene.java new file mode 100644 index 0000000..a2949fd --- /dev/null +++ b/src/main/java/Scene.java @@ -0,0 +1,5 @@ +import java.awt.Graphics; + +public abstract class Scene { + abstract void render(Graphics g); +} 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(); + } +} diff --git a/src/main/java/Tile.java b/src/main/java/Tile.java new file mode 100644 index 0000000..cbdeda4 --- /dev/null +++ b/src/main/java/Tile.java @@ -0,0 +1,15 @@ +public class Tile { + + public enum Type { + GRASS, + }; + + public final int x, y; + public final Type type; + + public Tile(Type type, int x, int y) { + this.type = type; + this.x = x; + this.y = y; + } +} diff --git a/src/main/java/WorldScene.java b/src/main/java/WorldScene.java new file mode 100644 index 0000000..6dff04a --- /dev/null +++ b/src/main/java/WorldScene.java @@ -0,0 +1,32 @@ +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; + + +public class WorldScene extends Scene { + + private Actor actors[]; + private Map map; + + private int tileSize; + + public WorldScene(Dimension gridSize, int tileSize) { + this.tileSize = tileSize; + map = new Map(gridSize); + } + + @Override + public void render(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + for (Tile tile : this.map.grid) { + g2d.setColor(Color.GREEN); + g2d.fillRect( + this.tileSize * tile.x, + this.tileSize * tile.y, + this.tileSize, this.tileSize + ); + } + } +} -- cgit v1.2.1