aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-02-10 13:44:36 +0100
committerNao Pross <naopross@thearcway.org>2018-02-10 13:44:36 +0100
commit7eb82d91aa34aba1a20bc47e726dffc50cdee0c4 (patch)
treea5bfca8521fd1ce7ff49981f4dc6d17cefbe336d
parentFirst commit (diff)
downloadSubconscious-old-master.tar.gz
Subconscious-old-master.zip
CleanupHEADmaster
-rw-r--r--Makefile18
-rw-r--r--README.md6
-rw-r--r--src/EntityType.java3
-rw-r--r--src/MainPanel.java265
-rw-r--r--src/Subconscious.java24
-rw-r--r--src/Tile.java22
-rw-r--r--src/TileType.java3
7 files changed, 6 insertions, 335 deletions
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 13da9d5..0000000
--- a/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-MAINCLASS := Subconscious
-
-run: build
- cd bin && java $(MAINCLASS)
-
-pack: build
- echo "Main-Class: $(MAINCLASS)" > jar/manifest.txt
- jar cvfm jar/$(MAINCLASS).jar jar/manifest.txt -C bin/ .
-
-build: dirs
- javac -d bin/ src/*.java
-
-dirs:
- mkdir -p src bin jar
-
-clean:
- rm jar/*
- rm bin/*
diff --git a/README.md b/README.md
index e69de29..9b26a0a 100644
--- a/README.md
+++ b/README.md
@@ -0,0 +1,6 @@
+# Subconcious
+This repository contains the source code of the entire game
+
+# Development
+The `master` branch always contains a working version. The development
+is done in the `dev` branch.
diff --git a/src/EntityType.java b/src/EntityType.java
deleted file mode 100644
index a4ccf30..0000000
--- a/src/EntityType.java
+++ /dev/null
@@ -1,3 +0,0 @@
-public enum EntityType {
- NULL, PLAYER, ENEMY, TREE
-}
diff --git a/src/MainPanel.java b/src/MainPanel.java
deleted file mode 100644
index 8af12ee..0000000
--- a/src/MainPanel.java
+++ /dev/null
@@ -1,265 +0,0 @@
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.*;
-import java.util.Random;
-
-public class MainPanel extends JPanel implements MouseListener, MouseMotionListener {
-
- public int width = 20;
- public Tile[][] tileArray = new Tile[width][width];
- public int size;
- public boolean selectionMode = false;
- public boolean attackMode = false;
- public boolean action = false;
- public boolean miss = false;
- public int[] selection = {0, 0};
- public int[] attaction = {0, 0};
- public int[] location = {0, 0};
- private int len;
- private Color RED = new Color(165, 66, 66);
- private Color YELLOW = new Color(250, 198, 116);
- private Color GREEN = new Color(181, 189, 104);
- private Color BLACK = new Color(29, 31, 33);
- private Color WHITE = new Color(197, 200, 198);
- private Color BLUE = new Color(95, 129, 157);
- private Color ORANGE = new Color(222, 147, 95);
- private Color DARKGREEN = new Color(140, 148, 64);
- private Color BROWN = new Color(51, 41, 33);
- private Random rand = new Random();
-
- public MainPanel () {
- for (int row = 0; row < width; row++) {
- for (int col = 0; col < width; col++) {
- tileArray[row][col] = new Tile(row, col, this.size, this.width);
- }
- }
-
- tileArray[0][0].entityType = EntityType.PLAYER;
- for (int i = 0; i < 35; i++) {
- int row = rand.nextInt(width);
- int col = rand.nextInt(width);
- int type = rand.nextInt(4);
- if (tileArray[row][col].entityType == EntityType.NULL) {
- if (type == 0) {
- tileArray[row][col].entityType = EntityType.ENEMY;
- } else {
- tileArray[row][col].entityType = EntityType.TREE;
- }
- }
- }
-
- this.addMouseListener(this);
- this.addMouseMotionListener(this);
- }
-
- public void paintComponent(Graphics g) {
- if (this.getWidth() > this.getHeight()) {
- this.size = this.getHeight();
- } else {
- this.size = this.getWidth();
- }
-
- super.paintComponent(g);
-
- Graphics2D g2d = (Graphics2D) g.create();
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
-
- int bar = this.size/20;
-
- g2d.setColor(WHITE);
- g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
- g2d.setColor(BLACK);
- g2d.fillRect(0, this.size-bar, this.size-bar, bar);
- g2d.setColor(WHITE);
- g2d.setFont(new Font("Arial", Font.BOLD, bar-bar/10));
- if (this.miss) {
- g2d.drawString("MISS", this.size-bar-(bar-bar/10)*3, this.size-bar/10);
- }
-
- if (action) {
- g2d.drawString("PAS", 0, this.size-bar/10);
- g2d.drawString("ATK", (bar-bar/10)*3, this.size-bar/10);
- }
-
- for (int row = 0; row < width; row++) {
- for (int col = 0; col < width; col++) {
- this.tileArray[row][col].calc(row, col, this.size-bar);
- int x = this.tileArray[row][col].x;
- int y = this.tileArray[row][col].y;
- this.len = this.tileArray[row][col].len;
-
- int border = len/100;
-
- if (this.tileArray[row][col].tileType == TileType.GRASS) {
- g2d.setColor(GREEN);
- g2d.fillRect(x, y, len, len);
- g2d.setColor(BLACK);
- g2d.setStroke(new BasicStroke(len/50));
- g2d.drawRect(x, y, len, len);
- } else if (
- this.tileArray[row][col].tileType == TileType.WATER) {
- g2d.setColor(Color.BLUE);
- g2d.fillRect(x, y, len, len);
- g2d.setColor(BLACK);
- g2d.setStroke(new BasicStroke(len/50));
- g2d.drawRect(x, y, len, len);
- }
-
- int spacing = len/12;
-
-
- if (this.tileArray[row][col].entityType == EntityType.PLAYER) {
- g2d.setColor(BLUE);
- g2d.fillRect(
- x+spacing, y+spacing, len-spacing*2, len-spacing*2);
- this.location[0] = x;
- this.location[1] = y;
- this.selection[0] = row;
- this.selection[1] = col;
- }
-
- if (this.tileArray[row][col].entityType == EntityType.ENEMY) {
- g2d.setColor(RED);
- g2d.fillRect(
- x+spacing, y+spacing, len-spacing*2, len-spacing*2);
- }
-
- if (this.tileArray[row][col].entityType == EntityType.TREE) {
- g2d.setColor(DARKGREEN);
- g2d.fillRect(
- x+spacing, y+spacing, len-spacing*2, len-spacing*2);
- g2d.setColor(BROWN);
- g2d.fillRect(x+len/3, y+len/3, len/3, len/3);
- }
-
- if (this.tileArray[row][col].selected) {
- if (this.tileArray[row][col].entityType == EntityType.NULL) {
- g2d.setColor(YELLOW);
- g2d.fillRect(x+len/3, y+len/3, len/3, len/3);
- }
- }
-
- if (this.tileArray[row][col].attack) {
- g2d.setColor(ORANGE);
- g2d.setStroke(new BasicStroke(this.len/6));
- g2d.drawRect(x+len/4, y+len/4, len*2/4, len*2/4);
- }
- }
- }
-
- }
-
- public void mousePressed(MouseEvent e) {}
- public void mouseReleased(MouseEvent e) {}
- public void mouseEntered(MouseEvent e) {}
- public void mouseMoved(MouseEvent e) {
- int x = e.getX();
- int y = e.getY();
-
- if (attackMode) {
- for (int row = 0; row < width; row++) {
- for (int col = 0; col < width; col++) {
- this.tileArray[row][col].attack = false;
- if (
- x > this.tileArray[row][col].x
- && x < this.tileArray[row][col].x
- + this.tileArray[row][col].len
- && y > this.tileArray[row][col].y
- && y < this.tileArray[row][col].y
- + this.tileArray[row][col].len
- ) {
- this.tileArray[row][col].attack = true;
- }
- }
- }
- }
- this.repaint();
- }
- public void mouseExited(MouseEvent e) {}
- public void mouseDragged(MouseEvent e) {}
-
- public void mouseClicked(MouseEvent e) {
- int x = e.getX();
- int y = e.getY();
- int bar = this.size/20;
- boolean stop = false;
- this.miss = false;
-
- if (
- x > 0
- && x < (bar-bar/10)*3
- && y > this.size-bar
- && y < this.size
- ) {
- this.action = false;
- } else if (
- x > (bar-bar/10)*3
- && x < (bar-bar/10)*6
- && y > this.size-bar
- && y < this.size
- ) {
- this.attackMode = true;
- this.action = false;
- } else {
- for (int row = 0; row < width; row++) {
- for (int col = 0; col < width; col++) {
- if (
- x > this.tileArray[row][col].x
- && x < this.tileArray[row][col].x
- + this.tileArray[row][col].len
- && y > this.tileArray[row][col].y
- && y < this.tileArray[row][col].y
- + this.tileArray[row][col].len
- ) {
- if (this.selectionMode) {
- if (this.tileArray[row][col].selected) {
- this.tileArray[this.selection[0]][this.selection[1]].entityType = EntityType.NULL;
- this.tileArray[row][col].entityType = EntityType.PLAYER;
- this.selectionMode = false;
- this.action = true;
- }
- } else if (this.attackMode) {
- int dist = (int) Math.sqrt(Math.pow(row - this.selection[0], 2)
- + Math.pow(col - this.selection[1], 2));
- if (rand.nextInt(13) > dist) {
- if (this.tileArray[row][col].entityType == EntityType.ENEMY) {
- this.tileArray[row][col].entityType = EntityType.NULL;
- } else if (this.tileArray[row][col].entityType == EntityType.TREE) {
- this.tileArray[row][col].entityType = EntityType.NULL;
- }
- } else {
- this.miss = true;
- }
- this.tileArray[row][col].attack = false;
- this.attackMode = false;
- } else if (this.tileArray[row][col].entityType == EntityType.PLAYER) {
- this.selectionMode = true;
- this.selection[0] = row;
- this.selection[1] = col;
- for (int srow = -4; srow <= 4; srow++) {
- for (int scol = -4; scol <= 4; scol++) {
- if (Math.abs(srow) + Math.abs(scol) <= 4) {
- try {
- if (this.tileArray[row+srow][col+scol].entityType == EntityType.NULL) {
- this.tileArray[row+srow][col+scol].selected = true;
- }
- } catch (ArrayIndexOutOfBoundsException ex) {}
- }
- }
- }
- }
- }
- }
- }
- if (!selectionMode) {
- for (int row = 0; row < width; row++) {
- for (int col = 0; col < width; col++) {
- this.tileArray[row][col].selected = false;
- }
- }
- }
- }
- this.repaint();
- }
-}
diff --git a/src/Subconscious.java b/src/Subconscious.java
deleted file mode 100644
index dc15964..0000000
--- a/src/Subconscious.java
+++ /dev/null
@@ -1,24 +0,0 @@
-import javax.swing.*;
-import java.awt.*;
-
-public class Subconscious {
-
- public static final Dimension WINDOW_SIZE = new Dimension(400, 400);
-
- public Subconscious() {
- JFrame frame = new JFrame("Subconscious");
-
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(WINDOW_SIZE);
- frame.setLocationRelativeTo(null);
-
- MainPanel mainPanel= new MainPanel();
- frame.add(mainPanel);
-
- frame.setVisible(true);
- }
-
- public static void main(String[] args) {
- Subconscious subconscious = new Subconscious();
- }
-}
diff --git a/src/Tile.java b/src/Tile.java
deleted file mode 100644
index 8624f08..0000000
--- a/src/Tile.java
+++ /dev/null
@@ -1,22 +0,0 @@
-public class Tile {
-
- public int x;
- public int y;
- public int len;
- public TileType tileType = TileType.GRASS;
- public EntityType entityType = EntityType.NULL;
- public boolean selected = false;
- public boolean attack = false;
- public int width;
-
- public Tile (int row, int col, int window, int width) {
- this.width = width;
- this.calc(row, col, window);
- }
-
- public void calc (int row, int col, int window) {
- this.len = (int) (window/(double)this.width);
- this.x = col*len;
- this.y = row*len;
- }
-}
diff --git a/src/TileType.java b/src/TileType.java
deleted file mode 100644
index 82a5b5b..0000000
--- a/src/TileType.java
+++ /dev/null
@@ -1,3 +0,0 @@
-public enum TileType {
- GRASS, ROAD, HOUSE, WATER
-}