summaryrefslogtreecommitdiffstats
path: root/src/Battle.java
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-11-19 00:02:46 +0100
committerNao Pross <naopross@thearcway.org>2018-11-19 00:02:46 +0100
commitbf6bbd5609cd125d8b3e5a7fbe6f2cd49146af49 (patch)
treed16adf89b93b44c4a040725b54dbfe5ccf84ef14 /src/Battle.java
parentAdd gitignore, remove binaries (diff)
downloadSubconscious-java-master.tar.gz
Subconscious-java-master.zip
Add TODOs for various correctionsHEADmaster
Diffstat (limited to 'src/Battle.java')
-rw-r--r--src/Battle.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/Battle.java b/src/Battle.java
index d7b63cc..6f614eb 100644
--- a/src/Battle.java
+++ b/src/Battle.java
@@ -1,35 +1,48 @@
import java.util.ArrayList;
import java.util.Collections;
+
import java.awt.Canvas;
import java.awt.Graphics2D;
import java.awt.Dimension;
import java.awt.BorderLayout;
import java.awt.GridLayout;
+
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+
import java.awt.image.BufferStrategy;
+
import java.awt.geom.Point2D;
import java.awt.geom.NoninvertibleTransformException;
+
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
+// TODO: rename to BattleScene
public class Battle extends MapScene {
private enum Mode {
NONE, ATTACK, MOVE
};
+ // TODO: make sub observe this object to remove this reference
private Sub main;
+ // TODO: refractor, make Points()
private int previousX = -1;
private int previousY = -1;
+ // TODO: what the fuck is the difference between these two?
private Actor selectedActor;
private Actor lastActor;
+
private Mode mode;
+
private boolean actorClicked = false;
+
+ // TODO: these are the coordinates of the mouse => refractor names
private int realX = 0;
private int realY = 0;
@@ -44,6 +57,7 @@ public class Battle extends MapScene {
this.setLayout(new BorderLayout());
+ // TODO: make a method buildUi() ?
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new GridLayout(1,4));
@@ -167,8 +181,8 @@ public class Battle extends MapScene {
}
private void aiPlay() {
- //TODO write AI
- //controll back to the player
+ // TODO: write AI code
+ // give back control back to the player
this.map.resetActors();
this.selectedActor = this.map.getNextActor();
this.lastActor = this.selectedActor;
@@ -177,16 +191,21 @@ public class Battle extends MapScene {
@Override
public void mouseClicked(MouseEvent e) {
+
int tileSize = this.maxSize/10;
Point2D p = new Point2D.Double(e.getX(), e.getY());
+
try {
p = this.tx.inverseTransform(p, null);
} catch (NoninvertibleTransformException ex) {}
+
try {
+ // find actor under cursor
int x = (int) (p.getX()/tileSize);
int y = (int) (p.getY()/tileSize);
Tile tile = this.map.getTile(x, y);
Actor actor = null;
+
for (Actor i : this.map.getActors()) {
if (x == i.getX() && y == i.getY()) {
actor = i;
@@ -269,6 +288,7 @@ public class Battle extends MapScene {
@Override
public void actionPerformed(ActionEvent e) {
+ // TODO: rename Ui elements to ex. btn-move, btn-pass, ...
if ("move".equals(e.getActionCommand()) && this.selectedActor != null) {
this.map.clearSelected();
this.mode = Mode.MOVE;