Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Commit

Permalink
fix target
Browse files Browse the repository at this point in the history
  • Loading branch information
faceair committed Dec 29, 2017
1 parent a7bbef3 commit 2ea2717
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ func main() {
}
jumpCube = []int{jumpCube[0], jumpCube[1]}

target := []int{0, 0}
last := []int{0, 0, 0, 0}
possible := [][]int{}
for y := 0; y < h; y++ {
line := 0
bgColor := src.At(w-10, y)
Expand All @@ -86,32 +85,28 @@ func main() {
line++
} else {
if y > 200 && x-line > 10 && line > 35 && ((x-line/2) < (jumpCube[0]-20) || (x-line/2) > (jumpCube[0]+20)) {
if x <= last[3] {
target = []int{last[0], last[1]}
break
}
last = []int{x - line/2, y, line, x}
possible = append(possible, []int{x - line/2, y, line, x})
}
line = 0
}
}
if target[0] != 0 {
break
}
}
if target[0] == 0 {
target = last
target := possible[0]
for _, point := range possible {
if point[3] > target[3] && point[1]-target[1] <= 1 {
target = point
}
}
target = []int{target[0], target[1]}

ms := int(math.Pow(math.Pow(float64(jumpCube[0]-target[0]), 2)+math.Pow(float64(jumpCube[1]-target[1]), 2), 0.5) * ratio)

log.Printf("from:%v to:%v wait:%vms", jumpCube, target, ms)
log.Printf("from:%v to:%v press:%vms", jumpCube, target, ms)

_, err = exec.Command("adb", "shell", "input", "swipe", "320", "410", "320", "410", strconv.Itoa(ms)).Output()
if err != nil {
log.Fatal(err)
}

time.Sleep(time.Millisecond * time.Duration(ms+720))
time.Sleep(time.Millisecond * 1500)
}
}

0 comments on commit 2ea2717

Please sign in to comment.