1
0
mirror of https://github.com/davpapp/PowerMiner synced 2024-12-21 23:48:49 -05:00

Timing now working, will need refactoring

This commit is contained in:
davpapp 2018-01-31 00:04:07 -05:00
parent 06ca105591
commit eb5357335d
14 changed files with 59 additions and 18 deletions

BIN
bin/Constants.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/CursorTask.class Normal file

Binary file not shown.

Binary file not shown.

7
src/Constants.java Normal file
View File

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

View File

@ -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);
}
}
}*/
}

View File

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

View File

@ -27,15 +27,27 @@ public class CursorPath {
for (CursorPoint cursorPoint : cursorPoints) {
cursorPointsCopy.add(getOffsetCursorPoint(cursorPoint, startingCursorPoint));
}
calculatePostMillisecondDelays(cursorPointsCopy);
return cursorPointsCopy;
}
private void calculatePostMillisecondDelays(ArrayList<CursorPoint> 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
}

View File

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

16
src/CursorTask.java Normal file
View File

@ -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++) {
}
}
}
}

View File

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