1 Star 0 Fork 0

zwjtheone/jump_one_jump

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
jump.js 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
赵伟杰 提交于 2018-01-29 10:21 . first commit
/**
* Created by beiwan on 2017/12/29.
*/
const util = require("util");
const fs = require("fs");
const path = require("path");
const exec = util.promisify(require("child_process").exec);
const ADB_PATH = "adb";
const SCREENCAP_REMOTE_PATH = "/sdcard/screencap.png";
const SCREENCAP_PATH = path.resolve(".", "public/images/jump_screencap");
const BOOM = 4.88;
jumpGo = async (timeout) => {
const r = Math.random() * 20;
const { stdout } = await exec(`${ADB_PATH} shell input touchscreen swipe ${150 + r} ${200 + r} ${140 + r} ${100 + r} ${timeout}`);
console.log(stdout);
};
fetchScreenCap = async () => {
const { stdout, stderr } = await exec(`${ADB_PATH} shell /system/bin/screencap -p /sdcard/screenshot.png`);
console.log("fetch...");
pullScreenCap();
};
pullScreenCap = async () => {
const { stdout, stderr } = await exec(`adb pull /sdcard/screenshot.png C:\/Users\/Jay99\/Desktop\/you_jump_i_jump-master\/public\/images\/jump_screencap\/screencap.png`, []);
// adb pull /sdcard/screenshot.png C:\Users\Jay99\Desktop\you_jump_i_jump-master\public\images\jump_screencap
console.log("pull...");
};
distance = (start, end) => {
return Math.sqrt(Math.pow((start.x - end.x), 2) + Math.pow((start.y - end.y), 2));
};
iJump = async (distance) => {
await jumpGo(parseInt(distance * BOOM));
// await setTimeout(async () => {
// await fetchScreenCap();
// }, 100);
};
refreshScreencap = async () => {
await fetchScreenCap();
};
module.exports = {
iJump,
refreshScreencap
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/zwjtheone/jump_one_jump.git
git@gitee.com:zwjtheone/jump_one_jump.git
zwjtheone
jump_one_jump
jump_one_jump
master

搜索帮助