diff --git a/README.md b/README.md
index e870d57..43a25b7 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ adb pull /sdcard/screen.png # 下载截屏文件到本地
```
## 使用方法
-**当前最新代码版本为0.0.4**
+**当前最新代码版本为0.0.5**
1. 在电脑上下载好adb,并安装JDK7及以上版本以及配置好java环境变量
2. 打开安卓手机的usb调试模式并授权连接的电脑
> 如果是小米手机,在USB调试下方有``USB调试(安全设置)``打开允许模拟点击 感谢[@wotermelon](https://github.com/wotermelon)
@@ -42,7 +42,7 @@ java -jar playJumpJumpWithMouse.jar -a "C:\Users\Home\Desktop\platform-tools\adb
* 全自动模式(auto-mode):也就是挂机模式,不需要人工操作,启动后既可以自动识别算法自动帮你玩跳一跳.
## 一些需要注意的点
-* 有些安卓机并不能很好的使用adb exec-out,导致截屏异常,可以尝试使用[老代码](https://github.com/easyworld/PlayJumpJumpWithMouse/blob/0ba11f1968db2a46660562f1b27d3925eec1b9ce/src/com/company/AdbCaller.java)替换现有方法
+* 默认分辨率比例为:**675x1200**,如果你的手机分辨率不是该比例则必须设置-s参数后手动和半自动才能计算准确。比如mate10 pro的分辨率是1080x2160,则设置为**-s 675x1350**.
## 运行截图
![这是一个截图](https://github.com/easyworld/PlayJumpJumpWithMouse/raw/master/screenshot.png)
diff --git a/playJumpJumpWithMouse-0.0.5.jar b/playJumpJumpWithMouse-0.0.5.jar
new file mode 100644
index 0000000..d119eac
Binary files /dev/null and b/playJumpJumpWithMouse-0.0.5.jar differ
diff --git a/pom.xml b/pom.xml
index 8793bb3..1f1de56 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,12 +4,13 @@
com.company
playJumpJumpWithMouse
- 0.0.4
+ 0.0.5
jar
playJumpJumpWithMouse
http://maven.apache.org
+
UTF-8
diff --git a/src/main/java/com/company/playJumpJumpWithMouse/AdbCaller.java b/src/main/java/com/company/playJumpJumpWithMouse/AdbCaller.java
index f5c60d0..3a1ff3d 100644
--- a/src/main/java/com/company/playJumpJumpWithMouse/AdbCaller.java
+++ b/src/main/java/com/company/playJumpJumpWithMouse/AdbCaller.java
@@ -1,67 +1,120 @@
package com.company.playJumpJumpWithMouse;
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
public class AdbCaller {
- private static String adbPath = Constants.ADB_PATH;
+ private static String adbPath = Constants.ADB_PATH;
- private static String screenshotLocation = Constants.SCREENSHOT_LOCATION;
+ private static String screenshotLocation = Constants.SCREENSHOT_LOCATION;
- public static void setAdbPath(String adbPath) {
- AdbCaller.adbPath = adbPath;
- }
+ private static Boolean error = null;
- public static void setScreenshotLocation(String screenshotLocation) {
- AdbCaller.screenshotLocation = screenshotLocation;
- }
+ public static void setAdbPath(String adbPath) {
+ AdbCaller.adbPath = adbPath;
+ }
- /**
- * 调用adb长按屏幕
- *
- * @param timeMilli
- */
- public static void longPress(double timeMilli) {
- try {
- Process process = Runtime.getRuntime()
- .exec(adbPath + " shell input touchscreen swipe 170 187 170 187 " + (int) timeMilli);
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
- String s;
- while ((s = bufferedReader.readLine()) != null)
- System.out.println(s);
- process.waitFor();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
+ public static void setScreenshotLocation(String screenshotLocation) {
+ AdbCaller.screenshotLocation = screenshotLocation;
+ }
- /**
- * 改进的截图方法
- * 感谢 hxzqlh
- */
- public static void printScreen() {
+ /**
+ * 调用adb长按屏幕
+ *
+ * @param timeMilli
+ */
+ public static void longPress(double timeMilli, BufferedImage image) {
+ try {
+ int width = image.getWidth() / 3 + (int) (Math.random() * image.getWidth() / 3);
+ int height = image.getHeight() - 300 + (int) (Math.random() * 200);
+ Process process = Runtime.getRuntime()
+ .exec(adbPath + " shell input touchscreen swipe " + width + " " + height + " " + width + " " + height + " " + (int) timeMilli);
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
+ String s;
+ while ((s = bufferedReader.readLine()) != null)
+ System.out.println(s);
+ process.waitFor();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
- try {
- String[] args = new String[] { "bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation };
- String os = System.getProperty("os.name");
- if (os.toLowerCase().startsWith("win")) {
- args[0] = "cmd";
- args[1] = "/c";
- }
- Process p1 = Runtime.getRuntime().exec(args);
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p1.getErrorStream()));
- String s;
- while ((s = bufferedReader.readLine()) != null)
- System.out.println(s);
- p1.waitFor();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
+ /**
+ * 改进的截图方法
+ * 感谢 hxzqlh
+ * 当改进的截图方法不能正常执行时降级为常规方法
+ */
+ public static void printScreen() {
+ if (error != null && error) {
+ printScreenWithOld();
+ } else {
+ try {
+ String[] args = new String[]{"bash", "-c", adbPath + " exec-out screencap -p > " + screenshotLocation};
+ String os = System.getProperty("os.name");
+ if (os.toLowerCase().startsWith("win")) {
+ args[0] = "cmd";
+ args[1] = "/c";
+ }
+ Process p1 = Runtime.getRuntime().exec(args);
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p1.getErrorStream()));
+ String s;
+ while ((s = bufferedReader.readLine()) != null)
+ System.out.println(s);
+ p1.waitFor();
+ checkScreenSuccess();
+ } catch (IOException e) {
+ e.printStackTrace();
+ error = true;
+ printScreenWithOld();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static void checkScreenSuccess() throws IOException {
+ if (error == null) {
+ BufferedImage image = ImageIO.read(new File(screenshotLocation));
+ if (image == null) {
+ throw new IOException("cann't read file \"" + screenshotLocation + "\" into image object");
+ }
+ }
+ }
+
+ public static void printScreenWithOld() {
+ try {
+ Process p1 = Runtime.getRuntime().exec(adbPath + " shell screencap -p /sdcard/screenshot.png");
+ p1.waitFor();
+ Process p2 = Runtime.getRuntime().exec(adbPath + " pull /sdcard/screenshot.png " + screenshotLocation);
+ p2.waitFor();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static int getSize() {
+ try {
+ Process p = Runtime.getRuntime().exec("adb shell wm density");
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String line = bufferedReader.readLine();
+ String[] splis = line.split(" ");
+ return Integer.valueOf(splis[splis.length - 1]);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return 480;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(getSize());
+ }
}
diff --git a/src/main/java/com/company/playJumpJumpWithMouse/BackgroundImage4Panel.java b/src/main/java/com/company/playJumpJumpWithMouse/BackgroundImage4Panel.java
index d7818f8..b1a5d86 100644
--- a/src/main/java/com/company/playJumpJumpWithMouse/BackgroundImage4Panel.java
+++ b/src/main/java/com/company/playJumpJumpWithMouse/BackgroundImage4Panel.java
@@ -38,6 +38,8 @@ public class BackgroundImage4Panel extends javax.swing.JFrame {
private static int playMode = Constants.MODE_MANUAL;
+ private static BufferedImage bufferedImage;
+
/**
* Creates new form NewJFrame
*/
@@ -52,6 +54,8 @@ public BackgroundImage4Panel() {
*/
public static void main(String[] args) {
+ ScreenAdapter.SCREEN_DPI = AdbCaller.getSize();
+
final int resizedScreenWidth, resizedScreenHeight;
final double resizedDistancePressTimeRatio;
final int screenshotInterval;
@@ -158,7 +162,7 @@ private static void manualMode(final int resizedScreenWidth, final int resizedSc
protected void paintComponent(Graphics g) {
super.paintComponent(g);
try {
- BufferedImage bufferedImage = ImageIO.read(new File(screenshotPath));
+ bufferedImage = ImageIO.read(new File(screenshotPath));
BufferedImage newImage = new BufferedImage(resizedScreenWidth, resizedScreenHeight,
bufferedImage.getType());
if (playMode == Constants.MODE_SEMI_AUTO) {
@@ -196,7 +200,7 @@ public void mouseClicked(MouseEvent e) {
int distance = distance(firstPoint, secondPoint);
System.out.println("distance:" + distance);
isFirst = true;
- AdbCaller.longPress(distance * resizedDistancePressTimeRatio);// magic
+ AdbCaller.longPress(distance * resizedDistancePressTimeRatio, bufferedImage);// magic
// number
try {
Thread.sleep(screenshotInterval);// wait for screencap
@@ -264,7 +268,7 @@ public void run() {
+ "] , secondPoint = [x=" + secondPoint.x + ",y=" + secondPoint.y + "]");
ColorFilterFinder.updateLastShapeMinMax(bufferedImage, firstPoint, secondPoint);
distance = distance(firstPoint, secondPoint);
- AdbCaller.longPress(distance * resizedDistancePressTimeRatio);// magic
+ AdbCaller.longPress(distance * resizedDistancePressTimeRatio, bufferedImage);// magic
// number
try {
Thread.sleep(screenshotInterval);// wait for
diff --git a/src/main/java/com/company/playJumpJumpWithMouse/ColorFilterFinder.java b/src/main/java/com/company/playJumpJumpWithMouse/ColorFilterFinder.java
index 6a22ef6..130a171 100644
--- a/src/main/java/com/company/playJumpJumpWithMouse/ColorFilterFinder.java
+++ b/src/main/java/com/company/playJumpJumpWithMouse/ColorFilterFinder.java
@@ -15,11 +15,11 @@ public class ColorFilterFinder {
static Point startCenterPoint;
- static int lastShapeMinMax = 150;
+ static int lastShapeMinMax = ScreenAdapter.getShapeMinWidth();
public static Point findEndCenter(BufferedImage bufferedImage, Point startCenterPoint) {
ColorFilterFinder.startCenterPoint = startCenterPoint;
- bgColor = new Color(bufferedImage.getRGB(540, 700));
+ bgColor = new Color(bufferedImage.getRGB(bufferedImage.getWidth() / 2, 120));
Point tmpStartCenterPoint;
Point tmpEndCenterPoint;
@@ -29,7 +29,7 @@ public static Point findEndCenter(BufferedImage bufferedImage, Point startCenter
(int) startCenterPoint.getY());
Color lastColor = bgColor;
- for (int y = 600; y < startCenterPoint.y; y++) {
+ for (int y = bufferedImage.getWidth() / 3; y < startCenterPoint.y; y++) {
for (int x = 10; x < bufferedImage.getWidth(); x++) {
if (rectangle.contains(x, y)) {
continue;
@@ -38,9 +38,9 @@ public static Point findEndCenter(BufferedImage bufferedImage, Point startCenter
if ((Math.abs(newColor.getRed() - lastColor.getRed())
+ Math.abs(newColor.getBlue() - lastColor.getBlue())
+ Math.abs(newColor.getGreen() - lastColor.getGreen()) >= 20)
- || (Math.abs(newColor.getRed() - lastColor.getRed()) >= 15
- || Math.abs(newColor.getBlue() - lastColor.getBlue()) >= 15
- || Math.abs(newColor.getGreen() - lastColor.getGreen()) >= 15)) {
+ || (Math.abs(newColor.getRed() - lastColor.getRed()) >= 10
+ || Math.abs(newColor.getBlue() - lastColor.getBlue()) >= 10
+ || Math.abs(newColor.getGreen() - lastColor.getGreen()) >= 10)) {
// System.out.println(BufferImageTest.toHexFromColor(newColor));
// System.out.println(BufferImageTest.toHexFromColor(lastColor));
// System.out.println("y = " + y + " x = " + x);
@@ -49,6 +49,7 @@ public static Point findEndCenter(BufferedImage bufferedImage, Point startCenter
tmpEndCenterPoint = findEndCenterPoint(bufferedImage, tmpStartCenterPoint);
return new Point(tmpStartCenterPoint.x, (tmpEndCenterPoint.y + tmpStartCenterPoint.y) / 2);
}
+ lastColor = newColor;
}
}
return null;
@@ -74,11 +75,11 @@ private static Point findEndCenterPoint(BufferedImage bufferedImage, Point tmpSt
centY = i;
}
}
- if (centY - tmpStartCenterPoint.y < 40) {
- centY = centY + 40;
+ if (centY - tmpStartCenterPoint.y < ScreenAdapter.getMinShapeHeight()) {
+ centY = centY + ScreenAdapter.getMinShapeHeight();
}
- if (centY - tmpStartCenterPoint.y > 230) {
- centY = tmpStartCenterPoint.y + 230;
+ if (centY - tmpStartCenterPoint.y > ScreenAdapter.getMaxShapeHeight()) {
+ centY = tmpStartCenterPoint.y + ScreenAdapter.getMaxShapeHeight();
}
return new Point(centX, centY);
}
@@ -92,8 +93,8 @@ private static Point findStartCenterPoint(BufferedImage bufferedImage, int x, in
if ((Math.abs(newColor.getRed() - lastColor.getRed()) + Math.abs(newColor.getBlue() - lastColor.getBlue())
+ Math.abs(newColor.getGreen() - lastColor.getGreen()) >= 20)
|| (Math.abs(newColor.getRed() - lastColor.getRed()) >= 15
- || Math.abs(newColor.getBlue() - lastColor.getBlue()) >= 15
- || Math.abs(newColor.getGreen() - lastColor.getGreen()) >= 15)) {
+ || Math.abs(newColor.getBlue() - lastColor.getBlue()) >= 15
+ || Math.abs(newColor.getGreen() - lastColor.getGreen()) >= 15)) {
centX = x + (i - x) / 2;
} else {
break;
@@ -106,7 +107,7 @@ private static boolean like(Color a, Color b) {
return !((Math.abs(a.getRed() - b.getRed()) + Math.abs(a.getBlue() - b.getBlue())
+ Math.abs(a.getGreen() - b.getGreen()) >= 20)
|| (Math.abs(a.getRed() - b.getRed()) >= 15 || Math.abs(a.getBlue() - b.getBlue()) >= 15
- || Math.abs(a.getGreen() - b.getGreen()) >= 15));
+ || Math.abs(a.getGreen() - b.getGreen()) >= 15));
}
public static void updateLastShapeMinMax(BufferedImage bufferedImage, Point first, Point second) {
@@ -114,7 +115,7 @@ public static void updateLastShapeMinMax(BufferedImage bufferedImage, Point firs
for (int x = second.x; x < bufferedImage.getWidth(); x++) {
Color newColor = new Color(bufferedImage.getRGB(x, second.y));
if (like(newColor, bgColor)) {
- lastShapeMinMax = (int) Math.max((x - second.x) * 1.5, 150);
+ lastShapeMinMax = (int) Math.max((x - second.x) * 1.5, lastShapeMinMax);
break;
}
}
@@ -122,7 +123,7 @@ public static void updateLastShapeMinMax(BufferedImage bufferedImage, Point firs
for (int x = second.x; x >= 10; x--) {
Color newColor = new Color(bufferedImage.getRGB(x, second.y));
if (like(newColor, bgColor)) {
- lastShapeMinMax = (int) Math.max((second.x - x) * 1.5, 150);
+ lastShapeMinMax = (int) Math.max((second.x - x) * 1.5, lastShapeMinMax);
break;
}
}
diff --git a/src/main/java/com/company/playJumpJumpWithMouse/Constants.java b/src/main/java/com/company/playJumpJumpWithMouse/Constants.java
index 3b8f960..77daee8 100644
--- a/src/main/java/com/company/playJumpJumpWithMouse/Constants.java
+++ b/src/main/java/com/company/playJumpJumpWithMouse/Constants.java
@@ -34,6 +34,12 @@ public class Constants {
*/
public static final int SCREENSHOT_INTERVAL = 3000; // ms
+ public static final int HDPI = 320;
+
+ public static final int XHDPI = 480;
+
+ public static final int XXHDPI = 640;
+
/**
* 手动模式
*/
diff --git a/src/main/java/com/company/playJumpJumpWithMouse/EndCenterFinder.java b/src/main/java/com/company/playJumpJumpWithMouse/EndCenterFinder.java
index c7422da..9d07c53 100644
--- a/src/main/java/com/company/playJumpJumpWithMouse/EndCenterFinder.java
+++ b/src/main/java/com/company/playJumpJumpWithMouse/EndCenterFinder.java
@@ -25,7 +25,7 @@ public static Point findEndCenter(BufferedImage bufferedImage, Point startCenter
int centerX = 0;
int centerY = 0;
int height = bufferedImage.getHeight() * 2 / 3;
- for (int h = 200; h < height && h < startCenterPoint.y; h++) {
+ for (int h = bufferedImage.getHeight() / 3; h < height && h < startCenterPoint.y; h++) {
for (int w = 0; w < width; w++) {
int color = bufferedImage.getRGB(w, h);
Color newColor = new Color(color);
@@ -74,7 +74,7 @@ static Point findWhiteCenter(BufferedImage bufferedImage, int x, int y, Point st
}
}
int centerY = minY + (maxY - minY) / 2;
- if (maxY - minY < 18) {
+ if (maxY - minY < ScreenAdapter.getMinWhiteHeight()) {
return null;
}
return new Point((int) (maxX * scaleX), (int) ((centerY)));
diff --git a/src/main/java/com/company/playJumpJumpWithMouse/ScreenAdapter.java b/src/main/java/com/company/playJumpJumpWithMouse/ScreenAdapter.java
new file mode 100644
index 0000000..1cfb89e
--- /dev/null
+++ b/src/main/java/com/company/playJumpJumpWithMouse/ScreenAdapter.java
@@ -0,0 +1,100 @@
+package com.company.playJumpJumpWithMouse;
+
+/**
+ * Created by tangshuai on 2018/1/2.
+ */
+public class ScreenAdapter {
+
+
+ static final int[] centers_xhdpi = new int[]{
+ -13948087, -13948087, -13948087, -13948087, -13947830, -13882036, -13816755, -13816755, -13750960, -13750960,
+ -13684910, -13684653, -13618603, -13553065, -13552808, -13487014, -13420964, -13420964, -13420964, -13420706,
+ -13420192, -13354656, -13158303, -13158303, -13223582, -13157789, -13026973, -13026973, -13092509, -13157789,
+ -13092509, -13026973, -13092510, -13158302, -13092766, -13026973, -13026973, -13026973, -13026973, -13026973,
+ -13026973, -13092766, -13158303, -13158303, -13092510, -13092510, -13026973, -13092510, -13158303, -13026973,
+ -13026973, -13092766, -13092510, -13026973, -13092766, -13158303, -13158303, -13092767, -13027489, -13027489,
+ -13027489, -13027489, -13027489, -13027489, -13027490, -13027747, -13027749, -13027496, -13027496, -12961961,
+ -12962219, -12962218, -12896682, -12830381, -12830381};
+
+
+ static final int[] centers_xxhdpi = new int[]{
+ -13948087, -13948087, -13948087, -13947830, -13948087, -13948087, -13948087, -13947830, -13816755, -13816755,
+ -13750960, -13684910, -13618603, -13553065, -13816755, -13816755, -13750960, -13684910, -13618603, -13553065,
+ -13487014, -13420964, -13420964, -13420706, -13354656, -13158303, -13487014, -13420964, -13420964, -13420706,
+ -13354656, -13158303, -13223582, -13157789, -13026973, -13092509, -13092509, -13026973, -13223582, -13157789,
+ -13026973, -13092509, -13092509, -13026973, -13158302, -13092766, -13026973, -13026973, -13026973, -13026973,
+ -13158302, -13092766, -13026973, -13026973, -13026973, -13026973, -13158303, -13158303, -13092510, -13026973,
+ -13158303, -13026973, -13158303, -13158303, -13092510, -13026973, -13158303, -13026973, -13092766, -13092510,
+ -13092766, -13158303, -13092767, -13027489, -13092766, -13092510, -13092766, -13158303, -13092767, -13027489,
+ -13027489, -13027489, -13027489, -13027490, -13027749, -13027496, -13027489, -13027489, -13027489, -13027490,
+ -13027749, -13027496, -12961961, -12962219, -12896682, -12830381, -12961961, -12962219, -12896682, -12830381};
+
+ static final int[] centers_hdpi = new int[]{
+ -13948087, -13948087, -13948087, -13947830, -13816755, -13816755, -13750960, -13684910, -13618603, -13553065,
+ -13487014, -13420964, -13420964, -13420706, -13354656, -13158303, -13223582, -13157789, -13026973, -13092509,
+ -13092509, -13026973, -13158302, -13092766, -13026973, -13026973, -13026973, -13026973, -13158303, -13158303,
+ -13092510, -13026973, -13158303, -13026973, -13092766, -13092510, -13092766, -13158303, -13092767, -13027489,
+ -13027489, -13027489, -13027489, -13027490, -13027749, -13027496, -12961961, -12962219, -12896682, -12830381};
+
+ public static int SCREEN_DPI = Constants.XHDPI;
+
+ public static int getShapeMinWidth() {
+ if (SCREEN_DPI >= Constants.XXHDPI) {
+ return 200;
+ } else if (SCREEN_DPI >= Constants.XHDPI) {
+ return 150;
+ } else {
+ return 100;
+ }
+ }
+
+ public static int[] getCenterArrays() {
+ if (SCREEN_DPI >= Constants.XXHDPI) {
+ return centers_xxhdpi;
+ } else if (SCREEN_DPI >= Constants.XHDPI) {
+ return centers_xhdpi;
+ } else {
+ return centers_hdpi;
+ }
+ }
+
+ public static int getBabyWidth() {
+ if (SCREEN_DPI >= Constants.XXHDPI) {
+ return 100;
+ } else if (SCREEN_DPI >= Constants.XHDPI) {
+ return 75;
+ } else {
+ return 50;
+ }
+ }
+
+ public static int getMaxShapeHeight() {
+ if (SCREEN_DPI >= Constants.XXHDPI) {
+ return 345;
+ } else if (SCREEN_DPI >= Constants.XHDPI) {
+ return 230;
+ } else {
+ return 173;
+ }
+ }
+
+ public static int getMinShapeHeight() {
+ if (SCREEN_DPI >= Constants.XXHDPI) {
+ return 52;
+ } else if (SCREEN_DPI >= Constants.XHDPI) {
+ return 40;
+ } else {
+ return 26;
+ }
+ }
+
+ public static int getMinWhiteHeight(){
+ if (SCREEN_DPI >= Constants.XXHDPI) {
+ return 24;
+ } else if (SCREEN_DPI >= Constants.XHDPI) {
+ return 18;
+ } else {
+ return 12;
+ }
+ }
+}
diff --git a/src/main/java/com/company/playJumpJumpWithMouse/StartCenterFinder.java b/src/main/java/com/company/playJumpJumpWithMouse/StartCenterFinder.java
index 20f523c..a96a640 100644
--- a/src/main/java/com/company/playJumpJumpWithMouse/StartCenterFinder.java
+++ b/src/main/java/com/company/playJumpJumpWithMouse/StartCenterFinder.java
@@ -9,15 +9,7 @@
*/
public class StartCenterFinder {
- static final int[] centers = new int[] { -13948087, -13948087, -13948087, -13948087, -13947830, -13882036,
- -13816755, -13816755, -13750960, -13750960, -13684910, -13684653, -13618603, -13553065, -13552808,
- -13487014, -13420964, -13420964, -13420964, -13420706, -13420192, -13354656, -13158303, -13158303,
- -13223582, -13157789, -13026973, -13026973, -13092509, -13157789, -13092509, -13026973, -13092510,
- -13158302, -13092766, -13026973, -13026973, -13026973, -13026973, -13026973, -13026973, -13092766,
- -13158303, -13158303, -13092510, -13092510, -13026973, -13092510, -13158303, -13026973, -13026973,
- -13092766, -13092510, -13026973, -13092766, -13158303, -13158303, -13092767, -13027489, -13027489,
- -13027489, -13027489, -13027489, -13027489, -13027490, -13027747, -13027749, -13027496, -13027496,
- -12961961, -12962219, -12962218, -12896682, -12830381, -12830381 };
+ static int[] centers = ScreenAdapter.getCenterArrays();
public static Point findStartCenter(BufferedImage bufferedImage) {
int width = bufferedImage.getWidth();
@@ -29,10 +21,10 @@ public static Point findStartCenter(BufferedImage bufferedImage) {
int color = bufferedImage.getRGB(w, h);
if (color == centers[0]) {
if (checkIsCenter(bufferedImage, h, w)) {
- centerX = w + 38;
+ centerX = w + ScreenAdapter.getBabyWidth() / 2;
centerY = h;
- return new Point(centerX, (centerY + 3));
+ return new Point(centerX, (centerY + 2));
}
}
}
@@ -40,7 +32,7 @@ public static Point findStartCenter(BufferedImage bufferedImage) {
}
private static boolean checkIsCenter(BufferedImage bufferedImage, int h, int w) {
- for (int i = w; i < w + 75; i++) {
+ for (int i = w; i < w + 50; i++) {
int color = bufferedImage.getRGB(i, h);
Color centerColor = new Color(centers[i - w]);
Color newColor = new Color(color);