Changeset 110 for java-automator/src/nl/rickvanderzwet/farmville
- Timestamp:
- Apr 13, 2010, 8:17:42 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java-automator/src/nl/rickvanderzwet/farmville/Automator.java
r107 r110 23 23 UP, DOWN, LEFT, RIGHT 24 24 } 25 26 /* Constants */ 27 static Integer FARMSIZE_Y = 7; 28 static Integer FARMSIZE_X = 22; 29 static boolean mouseClickEnabled = false; 25 30 31 26 32 private static Robot bot = null; 27 33 private static Random randomGenerator = null; 28 static boolean mouseClickEnabled = false;29 34 35 /* Parcel size in pixels */ 36 static Integer XMOVE = 22; 37 static Integer YMOVE = 11; 30 38 31 39 private static void pressMouse() throws InterruptedException { … … 46 54 /* Relocate to next field */ 47 55 Point mouse = MouseInfo.getPointerInfo().getLocation(); 48 Integer XMOVE = 22; 49 Integer YMOVE = 11; 56 57 /* Grumble half pixels moves are not possible, this will hack around it */ 58 XMOVE = (XMOVE == 22) ? XMOVE-- : XMOVE++; 59 YMOVE = (YMOVE == 11) ? YMOVE-- : YMOVE++; 60 61 50 62 51 63 Point newLocation = mouse; … … 101 113 */ 102 114 103 /* Constants */104 Integer farm_size_y = 1;105 Integer farm_size_x = 22;106 115 /* 0 = up, 1 = down, 2 = left, 3 = right */ 107 116 108 117 pressMouse(); 109 118 110 Direction direction = Direction. UP;119 Direction direction = Direction.RIGHT; 111 120 112 // Save the mouse button :-)113 for (int i = 0; i < farm_size_y; i++) {114 for (int j = 0; j < farm_size_x; j++) {121 /* Move around naturally, from top left, to bottom right */ 122 for (int i = 0; i < FARMSIZE_Y; i++) { 123 for (int j = 0; j < FARMSIZE_X; j++) { 115 124 pointer = MouseInfo.getPointerInfo(); 116 125 mouse = pointer.getLocation(); … … 127 136 } 128 137 129 moveMouse(Direction. LEFT);138 moveMouse(Direction.DOWN); 130 139 pressMouse(); 131 140 132 if (direction == Direction.UP) { 133 direction = Direction.DOWN; 134 } else { 135 direction = Direction.UP; 136 } 141 /* Flip direction around */ 142 direction = (direction == Direction.LEFT) ? Direction.RIGHT : Direction.LEFT; 143 137 144 } 138 145 } catch (AWTException e) {
Note:
See TracChangeset
for help on using the changeset viewer.