diff --git a/bin/Constants.class b/bin/Constants.class new file mode 100644 index 0000000..46c394e Binary files /dev/null and b/bin/Constants.class differ diff --git a/bin/Cursor.class b/bin/Cursor.class index b4336fe..f3f9915 100644 Binary files a/bin/Cursor.class and b/bin/Cursor.class differ diff --git a/bin/CursorDataFileParser.class b/bin/CursorDataFileParser.class index fa10e4d..b038cc9 100644 Binary files a/bin/CursorDataFileParser.class and b/bin/CursorDataFileParser.class differ diff --git a/bin/CursorPath.class b/bin/CursorPath.class index 0f1a2e0..6a78840 100644 Binary files a/bin/CursorPath.class and b/bin/CursorPath.class differ diff --git a/bin/CursorPoint.class b/bin/CursorPoint.class index 3f540e1..a982697 100644 Binary files a/bin/CursorPoint.class and b/bin/CursorPoint.class differ diff --git a/bin/CursorTask.class b/bin/CursorTask.class new file mode 100644 index 0000000..e096255 Binary files /dev/null and b/bin/CursorTask.class differ diff --git a/bin/main.class b/bin/main.class index 8af913e..8417973 100644 Binary files a/bin/main.class and b/bin/main.class differ diff --git a/src/Constants.java b/src/Constants.java new file mode 100644 index 0000000..573c239 --- /dev/null +++ b/src/Constants.java @@ -0,0 +1,7 @@ + +public class Constants { + public static final int GAME_WINDOW_WIDTH = 1000; + public static final int GAME_WINDOW_HEIGHT = 1000; + public static final int INVENTORY_WIDTH = 1000; + public static final int INVENTORY_HEIGHT = 1000; +} diff --git a/src/Cursor.java b/src/Cursor.java index 410df74..cd64374 100644 --- a/src/Cursor.java +++ b/src/Cursor.java @@ -60,6 +60,7 @@ public class Cursor { double angleToMoveCursor = calculateThetaBetweenPoints(startingCursorPoint, goalPoint); CursorPath cursorPathToFollow = chooseCursorPathToFollowBasedOnDistance(distanceToMoveCursor); + //cursorPathToFollow.displayCursorPoints(); double angleToTranslatePathBy = angleToMoveCursor - cursorPathToFollow.getCursorPathTheta(); followCursorPath(startingCursorPoint, angleToTranslatePathBy, cursorPathToFollow); } @@ -68,8 +69,7 @@ public class Cursor { for (CursorPoint untranslatedCursorPoint : cursorPathToFollow.getCursorPathPoints()) { Point translatedPointToClick = translatePoint(startingCursorPoint, angleToTranslatePathBy, untranslatedCursorPoint); robotMouseMove(translatedPointToClick); - int millisecondsToSleep = 50; - Thread.sleep(millisecondsToSleep); + Thread.sleep(untranslatedCursorPoint.postMillisecondDelay); } } @@ -100,10 +100,9 @@ public class Cursor { return MouseInfo.getPointerInfo().getLocation(); } - - public void displaycursorPathsByDistance() { + /*public void displaycursorPathsByDistance() { for (int i = 0; i < cursorPathsByDistance.size(); i++) { System.out.println("There are " + cursorPathsByDistance.get(i).size() + " CursorPaths of length " + i); } - } + }*/ } \ No newline at end of file diff --git a/src/CursorDataFileParser.java b/src/CursorDataFileParser.java index bb6274c..bd4accb 100644 --- a/src/CursorDataFileParser.java +++ b/src/CursorDataFileParser.java @@ -43,8 +43,8 @@ public class CursorDataFileParser { else { numberOfRepeats = 0; currentCursorPath.add(newCursorPoint); + lastCursorPoint = newCursorPoint; } - lastCursorPoint = newCursorPoint; } else { System.out.println("Skipping invalid REGEX: " + line); diff --git a/src/CursorPath.java b/src/CursorPath.java index 633dadf..7433980 100644 --- a/src/CursorPath.java +++ b/src/CursorPath.java @@ -27,15 +27,27 @@ public class CursorPath { for (CursorPoint cursorPoint : cursorPoints) { cursorPointsCopy.add(getOffsetCursorPoint(cursorPoint, startingCursorPoint)); } + calculatePostMillisecondDelays(cursorPointsCopy); return cursorPointsCopy; } + private void calculatePostMillisecondDelays(ArrayList cursorPoints) { + for (int i = 1; i < cursorPoints.size(); i++) { + cursorPoints.get(i - 1).setPostMillisecondDelay(cursorPoints.get(i).postMillisecondDelay - cursorPoints.get(i - 1).postMillisecondDelay); + } + cursorPoints.get(cursorPoints.size() - 1).setPostMillisecondDelay(0); + } + private CursorPoint getOffsetCursorPoint(CursorPoint cursorPoint, CursorPoint offsetPoint) { - return new CursorPoint(cursorPoint.x - offsetPoint.x, cursorPoint.y - offsetPoint.y,cursorPoint.time - offsetPoint.time); + return new CursorPoint(cursorPoint.x - offsetPoint.x, cursorPoint.y - offsetPoint.y, cursorPoint.postMillisecondDelay); } private int calculateCursorPathTimespan() { - return getEndingCursorPoint().time - getStartingCursorPoint().time; + int sumPathTimespanMilliseconds = 0; + for (CursorPoint cursorPoint : this.pathCursorPoints) { + sumPathTimespanMilliseconds += cursorPoint.postMillisecondDelay; + } + return sumPathTimespanMilliseconds; } private int calculateCursorPathDistance() { @@ -90,8 +102,9 @@ public class CursorPath { public void displayCursorPoints() { for (CursorPoint p : pathCursorPoints) { - System.out.println("(" + p.x + ", " + p.y + "), " + p.time); + p.display(); } System.out.println("Length:" + pathNumPoints + ", Timespan:" + pathTimespanMilliseconds); + System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~ End of Path ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); } } \ No newline at end of file diff --git a/src/CursorPoint.java b/src/CursorPoint.java index 2921208..d507062 100644 --- a/src/CursorPoint.java +++ b/src/CursorPoint.java @@ -2,11 +2,19 @@ public class CursorPoint { public int x; public int y; - public int time; + public int postMillisecondDelay; // how much to sleep for after moving here - public CursorPoint(int x, int y, int time) { + public CursorPoint(int x, int y, int postMillisecondDelay) { this.x = x; this.y = y; - this.time = time; + this.postMillisecondDelay = postMillisecondDelay; + } + + public void setPostMillisecondDelay(int postMillisecondDelay) { + this.postMillisecondDelay = postMillisecondDelay; + } + + public void display() { + System.out.println("Point: (" + x + "," + y + "), delay: " + postMillisecondDelay); } } \ No newline at end of file diff --git a/src/CursorTask.java b/src/CursorTask.java new file mode 100644 index 0000000..e8edb20 --- /dev/null +++ b/src/CursorTask.java @@ -0,0 +1,16 @@ +import java.awt.AWTException; + +public class CursorTask extends Cursor { + + public CursorTask() throws AWTException { + super(); + } + + public void dropAllItemsInInventory() { + for (int inventoryColumn = 0; inventoryColumn < 7; inventoryColumn++) { + for (int inventoryRow = 0; inventoryRow < 4; inventoryRow++) { + + } + } + } +} diff --git a/src/main.java b/src/main.java index a664f88..1cdbce8 100644 --- a/src/main.java +++ b/src/main.java @@ -2,15 +2,13 @@ import java.awt.AWTException; import java.awt.Point; import java.net.URL; + public class main { public static void main(String[] args) throws AWTException, InterruptedException { - // TODO Auto-generated method stub - - Cursor cursor = new Cursor(); - cursor.moveCursorToCoordinates(new Point(620, 420)); - //cursor.displaycursorPathsByDistance(); - //System.out.println("Finished..."); + Cursor cursor = new Cursor(); + //cursor.moveCursorToCoordinates(new Point(620, 420)); + } }